On 20/11/19 6:51 am, Andrew Barnert via Python-ideas wrote:
A class can bind attributes in __new__ and return a fully initialized
object. If that’s perfectly ok, why doesn’t every class do everything
in __new__, in which case there’s no reason for __init__ to exist at
all?

If Python had been designed with the ability to subclass built-in
immutable objects from the beginning, __init__ may well never have
existed.

I can't think of another language off the top of my head that splits
the functionality of object creation in quite this way. C++ lets
you override the 'new' operator, but that's strictly about allocating
memory, it doesn't do any initialisation.

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

Reply via email to