__init__ is the initialiser
ethan at stoneleaf.us
Sat Feb 1 03:45:19 CET 2014
On 01/31/2014 06:28 PM, Terry Reedy wrote:
> Construct a house:
> Clear and grade house site.
> Bring in power and water.
> Built temporary structures.
> Built foundation.
> Built house on foundation.
> For most classes, __new__ stops with the foundation -- the bare object object (with the class name slapped onto it). A
> *house* is not constructed until the house is constructed on top of the foundation.
On the ground programming has the dividing line at:
immutable objects --> everything done in __new__
mutable objects --> everything done in __init__
Typically, immutable objects are not created in Python code because, well, it's really dang hard (__slots__, anyone?),
but one still needs to understand how __new__ and __init__ go together to do the more interesting stuff (such as having
__new__ return a dynamically selected subclass, which still needs to be (or not be) __init__ed).
More information about the Python-list