[Tutor] Using superclass __init__ method

Kent Johnson kent37 at tds.net
Thu Sep 22 15:40:48 CEST 2005

Jan Eden wrote:
> Hi,
> I just noticed that in the following environment:
> class Base:
>     def __init__(self):
>         ...
> class Child(Base):
>     pass
> the following statement:
> child = Child()
> would automatically execute the superclass __init__ method. This is exactly what I was looking for - but in the Cookbook, I found several suggestions on how to actively force the invocation of the superclass __init__.
> Is this behvaiour documented?

This is standard behavior for any class attribute - if it's not defined in the derived class, the base class is checked. It's not special for __init__.

I can't find a comprehensive reference for the way attribute lookup works - anyone else?


More information about the Tutor mailing list