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.