[Python-Dev] Dataclasses, frozen and __post_init__
Greg Ewing
greg.ewing at canterbury.ac.nz
Tue Feb 20 18:49:09 EST 2018
More information about the Python-Dev mailing list
Tue Feb 20 18:49:09 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 ]
Chris Barker - NOAA Federal wrote: > If I have this right, on the discussion about frozen and hash, a use > case was brought up for taking a few steps to create an instance (and > thus wanting it not frozen) and then wanting it hashable. > > Which pointed to the idea of a “ freeze this from now on” method. The problem with a "freeze" method is that it doesn't play well with subclasses. The object ends up frozen by the base class's __new__ or __init__, preventing the subclass from doing its own initialisation unless it uses some form of back-door access. And if there is a back door, it might as well be used for all initialisation, maing the freeze method unnecessary. -- Greg
- 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