[Python-Dev] python and super
Greg Ewing
greg.ewing at canterbury.ac.nz
Sat Apr 16 01:48:54 CEST 2011
Mark Shannon wrote:
>>>> class A: pass
>>>> class B(A): pass
>>>> class C(A,B):pass
>
> Traceback (most recent call last):
> File "<stdin>", line 1, in <module>
> TypeError: Cannot create a consistent method resolution
> order (MRO) for bases B, A
All right, but this is okay:
class C(B, A): pass
> Michael Foord wrote:
>
>> For a super call in C, B is a sibling to A. For a super call in B, A
>> is a parent.
>>
>> With the semantics I was suggesting if C calls super, but A doesn't
>> then B would still get called.
which is contradicted by:
> "Siblings", in the context of a single MRO are thus classes between
> which there is no sub-class/super-class relation.
So I maintain that the situation is far from clear. :-)
--
Greg
More information about the Python-Dev
mailing list