__init__ is the initialiser

Mark Lawrence breamoreboy at yahoo.co.uk
Fri Jan 31 14:33:37 EST 2014


 From http://docs.python.org/3/reference/datamodel.html#object.__init__ 
which states:-

"
Called when the instance is created. The arguments are those passed to 
the class constructor expression. If a base class has an __init__() 
method, the derived class’s __init__() method, if any, must explicitly 
call it to ensure proper initialization of the base class part of the 
instance; for example: BaseClass.__init__(self, [args...]). As a special 
constraint on constructors, no value may be returned; doing so will 
cause a TypeError to be raised at runtime.
"

Should the wording of the above be changed to clearly reflect that we 
have an initialiser here and that __new__ is the constructor?

-- 
My fellow Pythonistas, ask not what our language can do for you, ask 
what you can do for our language.

Mark Lawrence




More information about the Python-list mailing list