Method Resolution Order
Method Resolution Order (MRO) is the sequence Python follows to search for a method or attribute across a class and its parent classes - especially important to understand when a class uses multiple inheritance.
Why MRO Matters
When a class inherits from more than one parent, and multiple parents define a method with the same name, Python needs a clear, consistent rule to decide which version actually gets called. That rule is the MRO.
class A:
def greet(self):
print("Hello from A")
class B(A):
def greet(self):
print("Hello from B")
class C(A):
def greet(self):
print("Hello from C")
class D(B, C):
pass
d = D()
d.greet() # Hello from B
Checking the MRO
You can inspect the exact resolution order Python will follow using the mro() method or the __mro__ attribute.
print(D.mro())
# [D, B, C, A, object]
Python uses an algorithm called C3 linearization to compute this order, which ensures a consistent, predictable search path: it checks the class itself first, then its parents left to right, without ever checking a parent before one of its own children.
Coming Up Next
Next, you'll learn about Overloading - how Python handles methods and operators that need to behave differently depending on their input.