News for hackers. Stuff that matters.
Re:The Data Classes Decorator by lcnmrn on Sunday December 12, 2021 @08:18AM (#29529382)
NamedTuples work with and without type hints, but Dataclasses only work with type hints: https://subreply.com/reply/lsk
Re:The Data Classes Decorator by ericvsmith on Sunday December 12, 2021 @12:54PM (#29531790)
dataclasses author here.

That's not true. You can use make_dataclass the same way you can use namedtuple:

  >>> from dataclasses import make_dataclass
  >>> A = make_dataclass("A", ["x", "y", "z"])
  >>> A(1, 2, 3)
  A(x=1, y=2, z=3)
It is true that if you want to use @dataclass you have to use annotations, just the way you do with typing.NamedTuple. But as others have noted, the annotation is mostly ignored.

[edited for formatting]

Re:The Data Classes Decorator by lcnmrn on Friday December 17, 2021 @03:19AM (#29589375)
Can you assign defaults with make_dataclass() but no types?