class Level1():
def __init__(self):
print("INIT of First...!!!")
class Level2_1(Level1):
def __init__(self):
super().__init__()
print("INIT of Second - First...!!!")
class Level2_2(Level1):
def __init__(self):
super().__init__()
print("INIT of Second - Second...!!!")
class Level2_3(Level1):
def __init__(self):
super().__init__()
print("INIT of Second - Third...!!!")
class Level3(Level2_1, Level2_2, Level2_3):
def __init__(self):
super().__init__()
print("INIT of Third...!!!")
class Combined(Level3):
def __init__(self):
super().__init__()
c = Combined()
print(Combined.__mro__)
# Real Execution Order: 1,2,4,5,8,9,12,13,16,17,20,21,23,22,18,6,10,14,3,15,11,7,19,24,25
# My guess: 1,2,4,5,8,9,12,13,16,17,20,21,23,22,18,6,3,7,10,11,14,15,19,24,25
'''Output:
INIT of First...!!!
INIT of Second - Third...!!!
INIT of Second - Second...!!!
INIT of Second - First...!!!
INIT of Third...!!!
(<class '__main__.Combined'>, <class '__main__.Level3'>, <class '__main__.Level2_1'>, <class '__main__.Level2_2'>, <class '__main__.Level2_3'>, <class '__main__.Level1'>, <class 'object'>)
'''
I must have not understood how super works. I thought it executes any class passed in the argument.