I can not find out the rules followed by python to make the linearization of the following class hierarchy:
class Type(type):
def __repr__(cls):
return cls.__name__
class O(object, metaclass=Type): pass
class F(O):pass
class E(O):pass
class D(O):pass
class C(D,F):pass
class B(E,D):pass
class A(B,C):pass
print(A.mro())
Getting:
[A, B, E, C, D, F, O, <class 'object'>]
I´m stuck in the following step:
L(A) : = [A] + merge(L(B), L(C),[B,C])
L(A) : = [A] + merge((B,E,D,O), (C,D,F,O) ,[B,C])
L(A) : = [A,B] + merge((E,D,O), (C,D,F,O) ,[C])
And here python chooses to go to:
L(A) : = [A,B,E] + merge((D,O), (C,D,F,O) ,[C])
instead of (what I´d have expected):
L(A) : = [A,B,C] + merge((E,D,O), (D,F,O))
Could you tell me the rule that applies here to choose class D instead of class C (that at first sight, has higher prevalence).
Thanks