Sobes.tech
Junior — Senior

Behavior of constructors in multiple inheritance

livecode

Task condition

Explain how initialization occurs when creating an instance of class Z, considering the order of super() calls and the inheritance scheme Z(X, Y).

class Base:
    def __init__(self):
        print('Base')

class X(Base):
    def __init__(self):
        super().__init__()
        print('X')

class Y(Base):
    def __init__(self):
        super().__init__()
        print('Y')

class Z(X, Y):
    def __init__(self):
        super().__init__()
        print('Z')

Z()