[Tutor] When to use __new__ vs. __init__ ?
Mats Wichmann
mats at wichmann.us
Wed Apr 29 10:37:43 EDT 2020
On 4/29/20 5:46 AM, Abhishek M wrote:
Is that a question?
Both are used during instantiation of a class instance, but they are
different things: one is used to create the object and the other to
initialize it.
It's pretty rare that you need to override __new__, while it is quite
common to set up a custom initialization function __init__ (which may of
course call up to the parent class __init__ using super()).
More information about the Tutor
mailing list