[Python-Dev] Dataclasses, frozen and __post_init__
Eric V. Smith
eric at trueblade.com
Tue Feb 20 16:37:33 EST 2018
More information about the Python-Dev mailing list
Tue Feb 20 16:37:33 EST 2018
- Previous message (by thread): [Python-Dev] Dataclasses, frozen and __post_init__
- Next message (by thread): [Python-Dev] Dataclasses, frozen and __post_init__
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
On 2/17/2018 2:35 PM, Guido van Rossum wrote: > PS. I have to ponder why frozen dataclasses don't use `__new__`. As I'm sure everyone is now aware after the rest of this discussion: it's because the returned object isn't really immutable. That said, I have threatened to create a decorator similar to typing.NamedTuple that has the @dataclass features (except maybe __post_init__) and returns a class that does inherit from tuple, in which case it really would use `__new__`. I'll save that for 3.8, if it ever happens. There's a lot there to think about, first. For now, typing.NamedTuple is the way to go if you want something based on namedtuple yet using type hints. Eric
- Previous message (by thread): [Python-Dev] Dataclasses, frozen and __post_init__
- Next message (by thread): [Python-Dev] Dataclasses, frozen and __post_init__
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
More information about the Python-Dev mailing list