Re: [Python-Dev] Dataclasses, frozen and __post_init__

2018-02-18 Thread Guido van Rossum
The underlying issue here is that we don't want an extra state flag in the object to indicate "this object is currently [im]mutable". Using __class__ assignment to signal this is clever way to add this state, though not without risks. On Sun, Feb 18, 2018 at 4:34 PM, Nick Coghlan wrote: > On 18

Re: [Python-Dev] Dataclasses, frozen and __post_init__

2018-02-18 Thread Nick Coghlan
On 18 February 2018 at 14:10, Guido van Rossum wrote: > Agreed the __pre_init__ idea is no improvement. I think we're back where you > started -- just use `object.__setattr__` to set the attribute in > `__post_init__`. That's what the PEP says is used by the generated > `__init__`, so I think it i

Re: [Python-Dev] Replacement proposal for PEP 557 Data Classes

2018-02-18 Thread Nick Coghlan
On 18 February 2018 at 09:14, Ramazan POLAT wrote: > Hi, I have been working on a new way to use Python classes as enhanced dict > object(I called it Prodict). > My solution is (IMHO) more concise and brings more features. > So I wanted to make it a PEP until I saw PEP 557 Data Classes. > With my