Multiple inheritance with a common base class

Markus Bertheau twanger at
Tue Aug 10 15:01:18 CEST 2004

В Втр, 10.08.2004, в 14:38, Duncan Booth пишет:

> Well of course it outputs 0 twice. That's because after LeafA initialised  
> CommonBase, and set its value to 3 you then reinitialised it from LeafB and 
> set the value back to 0.

Thanks for the explanation, Heiko too.

> Using super will ensure that you get a reliable chain of method calls. In 
> this case it means that Multi.__init__ calls LeafA.__init__ which calls 
> LeafB.__init__ which then calls CommonBase.__init__. Note that LeafA 
> propogates the call to LeafB even though LeafA has no knowledge of the 
> existence of LeafB.

That is what I needed to know. Thanks. It should probably be noted in
the paragraph about multiple inheritance.

(CommonBase has to be a new style class for python <= 2.3)


Markus Bertheau <twanger at>

More information about the Python-list mailing list