As I mentioned in the title I wonder why some __init__
methods are not called. Here is my example:
class Type(type):
def __repr__(cls):
return cls.__name__
class A(object, metaclass=Type):
def __init__(self):
print("A")
class B(A):
def __init__(self):
print("B1")
super().__init__()
print("B2")
class D(object, metaclass=Type):
def __init__(self):
print("D")
class E(B):
def __init__(self):
print("E1")
super().__init__()
print("E2")
class F(D, E):
def __init__(self):
print("F1")
super().__init__()
print("F2")
print(F.mro())
F()
which returns the order in which methods should be inherited (mro()
) and actual results:
[F, D, E, B, A, <class 'object'>]
F1
D
F2
Why the actual results are different from:
F1
D1
E1
B1
A
B2
E2
D2
F2
as the MRO would suggest?
I know the answer half way, that is, the lack of __init__
in A
's class definition breaks this chain, but why?