Python › Multiple Inheritance & MRO
How does cooperative multiple inheritance require every class in the hierarchy to call super() consistently, even in __init__?
AdvancedAnswer
For multiple inheritance to work correctly with shared behavior (like initialization), every class's __init__ (and other overridden methods) should call super().__init__(*args, **kwargs) rather than assuming a specific direct parent, so the call chains properly through the entire MRO. If any class in the chain omits the super() call, subsequent classes in the MRO are silently skipped, potentially leaving state uninitialized.
class Base:
def __init__(self):
print('Base init')
class Mixin1(Base):
def __init__(self):
print('Mixin1 init')
super().__init__()
class Mixin2(Base):
def __init__(self):
print('Mixin2 init')
super().__init__()
class Combined(Mixin1, Mixin2):
def __init__(self):
print('Combined init')
super().__init__()
Combined() # Combined, Mixin1, Mixin2, Base init -- all run exactly onceReal-world example A framework's mixin classes all consistently call super().__init__(**kwargs) so that combining any subset of mixins with a base class correctly initializes every class's state without any single mixin needing to know about the others.