Interview frequency: …
Short answer
The MRO (computed with the C3 algorithm) determines the order in which classes are searched for methods, and super() does not necessarily call the direct parent but the next class in the MRO of the actual object.
Explanation
You can see the order through ClassName.__mro__. In diamond-shaped inheritance, C3 guarantees each class appears once and after all of its subclasses. For cooperative inheritance to work, every class must call super(), accept **kwargs and pass along what it does not use. Use small single-purpose mixins, and avoid multiple inheritance merely for code reuse when composition is clearer.
Code example
class Base:
def save(self):
print("Base")
class Logged(Base):
def save(self):
print("Logged")
super().save()
class Validated(Base):
def save(self):
print("Validated")
super().save()
class Model(Logged, Validated):
pass
Model().save() # Logged → Validated → Base
print([c.__name__ for c in Model.__mro__])Common mistakes
- Calling Parent.method(self) directly in multiple inheritance, which runs the Base twice.
- Assuming super() always refers to the parent written in the class definition.