On 01/17/10 16:42, 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 ? > > if I have NO start values/variables to set, no Base Class __init__ to > call --- the __init__ method is NOT required, correct ?
No, __init__ is always required for new-style classes; however due to object inheritance (all new-style classes inherits from `object`), all new-style classes inherits the do-nothing __init__ from `object`. Essentially, it means __init__ can be omitted if it does the same as the super class' __init__. More generally, a method (e.g. MyClass.__init__) that does not override the superclass' method (e.g. MySuperClass.__init__) will use the superclass' definition of the method (i.e. when MyClass inherits from MySuperClass, and __init__ is not overrided in MyClass, MyClass.__init__ == MySuperClass.__init__). _______________________________________________ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor