A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from http://mail.python.org/pipermail/python-dev/2018-February/152201.html below:

[Python-Dev] Dataclasses, frozen and __post_init__

[Python-Dev] Dataclasses, frozen and __post_init__Greg Ewing greg.ewing at canterbury.ac.nz
Tue Feb 20 18:49:09 EST 2018
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
More information about the Python-Dev mailing list

RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4