[Tutor] Confirmation about __init__()

Alan Gauld alan.gauld at btinternet.com
Sun Jan 17 10:26:26 CET 2010

"Robert" <webtourist at gmail.com> wrote

>I have read quite a bit in the past 2 months, ( I have also looked at 
> At this point, I think I understand well what __init__() is and does -
> But, I have yet to see this *specifically* spelled out about the the
> __init__ method for a Class;
> It is OPTIONAL, correct ?

Yes as are all metods. There is nothing very special about __init__
except that it is not called explicitly by users of the class. It could 
been done as an explicit method as in Smalltalk or Objective C.
In these the instance creation paradigm is a two stage process

obj = [[class new] init]

In Python we get the init call for "free"

Alan G.

More information about the Tutor mailing list