[Tutor] Confirmation about __init__()

Steve Willoughby steve at alchemy.com
Sun Jan 17 07:16:15 CET 2010


Robert wrote:
> I have read quite a bit in the past 2 months, ( I have also looked at codes)
> 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 ?

In a manner of speaking, that's correct.  You'll get a basic default
initialization (and inherit the __init__() from your superclass(es) if
your new class is derived from another one.

You just create  your own __init__() if you have something you need to
set up, and/or need to call the superclass __init__() in a special way.



More information about the Tutor mailing list