Multiple Inheritance and MRO in Python
Python allows a class to inherit from multiple parent classes at once, and uses the Method Resolution Order (MRO) — computed via the C3 linearization algorit...
Published November 21, 2026
Python allows a class to inherit from several parents. The Method Resolution Order (MRO) defines the order Python searches them for an attribute, using the C3 linearisation algorithm so each class appears before its parents.
The concept
For class C(A, B), Python looks in C, then A, then B (then their parents) following the MRO. super() follows this same order, not just the 'direct parent'.
The diamond problem (A → B and C → D) is solved because A appears only once, after both B and C.
Diamond
A
/ \
B C
\ /
D D.__mro__ → D, B, C, A, object
Practical examples
See the MRO
class A: pass
class B(A): pass
class C(A): pass
class D(B, C): pass
D.__mro__ # (D, B, C, A, object)Cooperative super()
class A:
def hi(self): print('A')
class B(A):
def hi(self): print('B'); super().hi()
class C(A):
def hi(self): print('C'); super().hi()
class D(B, C):
def hi(self): print('D'); super().hi()
D().hi() # D B C AMixins
class JsonMixin:
def to_json(self): import json; return json.dumps(self.__dict__)
class User(JsonMixin): ...Common mistakes
- Parent orders that make the MRO impossible (TypeError).
- Not using super() consistently so some parents are skipped.
- Deep multi-inheritance hierarchies.
Key takeaways
- MRO decides lookup order.
- super() follows the MRO.
- Prefer small mixins or composition.
FAQ
How can I see the MRO?
Class.__mro__ or Class.mro().
Is multiple inheritance bad?
Fine for mixins; risky for deep hierarchies.