Multiple Class Inheritance Question

Andy Jewell andy at wild-flower.co.uk
Sun Jul 13 17:21:39 EDT 2003


On Sunday 13 Jul 2003 8:28 pm, YoTuco wrote:
> Does (can) an inheritance scheme like this have any adverse effects
> (pitt-falls) for the App class inheriting class 'A' twice?
>
> Thanx in advance for your input.
>
> class A:
>     A_attr = 'A'
>     ...
>     def A_methods(self):
>     ...
>
> class B(A):
>     def __init__(self):
>     ...
>
> class C(A):
>     def __init__(self):
>     ...
>
> class App(B,C):
>     def __init__(self):
>         B.__init__(self)
>         C.__init__(self)
>     ...


Read guildo's essay on new style classes - that explains it all.

In the 'old days' i.e. before Python 2.2.x the rules were different.  Now a 
new algorithm is used which copes better with this.  As I said, read the 
essay (it's on www.python.org - just search for 'new style classes essay').

hth
-andyj





More information about the Python-list mailing list