Interview Q&A / Object-Oriented Programming

AdvancedQuick answer1 min readUpdated 3 Oct 2026

What is the method resolution order (MRO) in Python?

SHORT ANSWER

MRO is the order in which Python searches a class and its parents when you call a method or read an attribute. Python builds it with the C3 rule, and you can see it in ClassName.__mro__.

Explain it simply

With several parents, Python needs a fixed queue to check for a method. The C3 rule guarantees that a child comes before its parents, and that parents keep the left-to-right order you wrote. So the search never visits a class twice.

super() in Python does not mean "my one parent". It means "the next class in the MRO".

Example

python
class A:
    def hi(self): return "A"
class B(A):
    def hi(self): return "B"
class C(A):
    def hi(self): return "C"
class D(B, C):
    pass

print(D().hi())                        # B
print([k.__name__ for k in D.__mro__]) # ['D', 'B', 'C', 'A', 'object']

D finds hi in B first because B is listed before C. A comes after both, so the diamond is visited once.

What to say in the interview

"MRO is Python's linearised search order for attributes across a class hierarchy, computed by C3 linearisation. It puts children before parents and keeps the declared order of bases. super() follows this order, which makes cooperative multiple inheritance work."

Common mistakes

  • Assuming super() always calls the direct parent. In multiple inheritance it calls the next class in the MRO.

#python#inheritance#mro

Related questions

Practise more Object-Oriented Programming questions

Test your recall with short answers, then return to the detailed explanations when you need context.

Open Object-Oriented Programming quick answers →

Get new questions like this by email

One short email when something new and useful lands. No spam, unsubscribe in one tap.

By subscribing you agree to the Privacy Policy.