def __init__(self):

Ben Finney ben+python at benfinney.id.au
Tue Apr 26 03:34:39 EDT 2016


Gary Herron <gherron at digipen.edu> writes:

>    The __init__ method is the constructor for instances of a class.  It
>    is not required, but the situations in which a constructor is not
>    needed are few and unusual.

That's needlessly confusing: ‘__init__’ is not a constructor because it
does not construct the instance. The ‘__new__’ method is the constructor
for a class (and returns the new instance).

The ‘__init__’ method requests the already-constructed instance to
initialise itself (and returns None).

-- 
 \         “I still have my Christmas Tree. I looked at it today. Sure |
  `\               enough, I couldn't see any forests.” —Steven Wright |
_o__)                                                                  |
Ben Finney




More information about the Python-list mailing list