How can I call a subclass method from parent class ?

bonono at bonono at
Thu Oct 20 13:07:34 CEST 2005

Thanks for the explanation but some how my code fail and since I don't
need multiple inheritance for the moment, I would settle for the not so
clean version.

The documentation of super is not very clear to me too. As seen in my
code, I am using classmethod which may cause some problem.

Steve Holden wrote:

> In point of fact super() is most useful when you *do* have multiple
> inheritance. The classic example is when classes B and C have a common
> supertype A, and then class D is a subclass of both B and C.
> Under these circumstances (the so-called "diamond-shaped inheritance
> graph") it can be problematic to ensure that each superclass's methods
> are called exactly once when methods are being extended rather than
> overridden: should a D call B's method, which then calls A's, and if so
> how does a D ensure that C's method gets called without it also calling
> A's method.
> Calls to super() are used to effectively place a linearised oredering on
> the superclasses to ansure that the diamond-shaped inheritance pattern
> is correctly handled to give the correct method resolution order.
> regards
>   Steve
> --
> Steve Holden       +44 150 684 7255  +1 800 494 3119
> Holden Web LLC           
> PyCon TX 2006        

More information about the Python-list mailing list