This was discussed here: https://bugs.python.org/issue46757

This came up because I had a dataclass subclass to flax.linen.Module that 
had its own post-init.  When I figured out that I needed to call super, I 
did so.   Later, when I refactored my code to remove the superclass, the 
super-call was broken.

It have been much simpler to always call super in __post_init__ from the 
start.  The proposal on the bug report was to get in the habit of doing:

if hasattr(super(), "__post_init__"): super().__post_init__() or: try: 
post_init = super().__post_init__ except AttributeError: pass else: 
post_init()

I think it will be difficult to convince projects to do this.

Best,

Neil
_______________________________________________
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/B77X2LJVQ4LEWEYL72AJSYQWKTYCII6A/
Code of Conduct: http://python.org/psf/codeofconduct/

Reply via email to