3 ms·
Hmm, perhaps there is no such thing as a constructor in Python then? As the documentation says, "__new__() and __init__() work together in constructing objects"
by ptx 5y ago
Hmm, perhaps there is no such thing as a constructor in Python then? As the documentation says, "__new__() and __init__() work together in constructing objects".
In Java's constructors you already have access to the instance (and could leak it outside the object if you wanted to) whereas in __new__ you don't, so it doesn't seem like __new__ by itself could be called the constructor either.
- kissgyorgy 5y agoYes, because only at the end of __new__ AND __init__ would the object be complete.