[Tutor] Calling super classs __init__?

Allen Fowler allen.fowler at yahoo.com
Wed Mar 19 18:22:32 CET 2008

> Nowadays the best practice for invoking a method from all superclasses
> (yes, multiple inheritance) is this:
> class SubClass(BaseClass):
>     def __init__(self, t, *args, **kw):
>         super(SubClass, self).__init__(*args, **kw)
>         # do something with t
> That way you let Python decide which superclasses your SubClass has,
> instead of hard-coding it in several places.

Excellent.  Thank you.  This seems far more logical.

Is there a proper way to handle the case when SubClass() is called using positional arguments, and you do not desire "t" to be at the beginning?

Thanks again,

Be a better friend, newshound, and 
know-it-all with Yahoo! Mobile.  Try it now.  http://mobile.yahoo.com/;_ylt=Ahu06i62sR8HDtDypao8Wcj9tAcJ

More information about the Tutor mailing list