Understanding Python's Method Resolution Order With Multiple Inheritance

Python lets a class inherit from more than one parent. That is powerful, and it raises a question every developer eventually meets: when two parents define the same method, which one runs?

The answer is the method resolution order, usually shortened to MRO. It is the rule Python uses to decide where to look for an attribute or method, and in what sequence. Once you understand it, multiple inheritance stops feeling unpredictable, super() stops feeling magical, and errors like Cannot create a consistent method resolution order become easy to diagnose.

This guide covers what the MRO is, how Python computes it with the C3 linearization algorithm, how super() follows it, how to build cooperative classes and mixins, and which mistakes to avoid. Every example runs on Python 3.

What Is Method Resolution Order in Python?

When you access obj.some_method, Python searches for the name in a specific sequence of classes. That sequence is the MRO. The first class in the sequence that defines the name wins.

With single inheritance the sequence is obvious: the class itself, its parent, its grandparent, and so on up to object. With multiple inheritance, several valid-looking orders exist, so Python needs a precise, deterministic rule.