newb __init__ inheritance

hyperboogie hyperboogie at
Mon Mar 12 10:09:36 CET 2012

On Thursday, March 8, 2012 5:25:06 PM UTC+2, hyperboogie wrote:
> Hello everyone.
> This is my first post in this group.
> I started learning python a week ago from the "dive into python" e-
> book and thus far all was clear.
> However today while reading chapter 5 about objects and object
> orientation I ran into something that confused me.
> it says here:
> "__init__ methods are optional, but when you define one, you must
> remember to explicitly call the ancestor's __init__ method (if it
> defines one). This is more generally true: whenever a descendant wants
> to extend the behavior of the ancestor, the descendant method must
> explicitly call the ancestor method at the proper time, with the
> proper arguments. "
> However later on in the chapter:
> it says:
> "Methods are defined solely by their name, and there can be only one
> method per class with a given name. So if a descendant class has an
> __init__ method, it always overrides the ancestor __init__ method,
> even if the descendant defines it with a different argument list. And
> the same rule applies to any other method. "
> My question is if __init__ in the descendant class overrides __init__
> in the parent class how can I call the parent's __init__ from the
> descendant class - I just overrode it didn't I?
> Am I missing something more fundamental here?
> Thanks

Thank you so much everyone for you help. No doubt I still have a long way to go before I feel comfortable with python.
Appreciate all your help...

More information about the Python-list mailing list