> If dataclass handled freezeable types (the objects are mutable until you call > freeze, > after which they’re not), this would be easy (frozen now just means > freezable, plus freeze > is called by the generated __init__ right after the __post_init__). But it > doesn’t, > because freezing is complicated. I don't really get your point here ...
> So, what else could you do? Make __setattr__ check the stack and see if it’s > being > called from type(self).__post_init__? Yes I think this is one possibility. >Add an extra hidden attribute to every instance just >to track whether you’re inside __post_init__ so __setattr__ can check it? This is better in my opinion. On top of this, to avoid having the extra hidden attribute maybe it would be possible to dynamically define the __setattr__ method in the end of the __post_init__ call. _______________________________________________ Python-ideas mailing list -- python-ideas@python.org To unsubscribe send an email to python-ideas-le...@python.org https://mail.python.org/mailman3/lists/python-ideas.python.org/ Message archived at https://mail.python.org/archives/list/python-ideas@python.org/message/GAFE7BLQPPZQQDIBMQHQLZW7BMF76A7R/ Code of Conduct: http://python.org/psf/codeofconduct/