What is the MRO?

Old style

Old style classes use DLR or depth-first left-to-right algorithm for MRO whereas new style classes use C3 Linearization algorithm for method resolution while doing multiple inheritances.

Diamond Problem

Python doesn't have this problem because of the method resolution order.

C3 linearization algorithm

C3 linearization algorithm enforces following constraints

C3 super-class linearization, it is based on 3 rules

  1. Inheritance graph determines the structure of method resolution order.
  2. Preserving local precedence ordering, i.e., visiting the super class only after the method of the local classes are visited.
  3. Monotonicity. If a class X precedes class Y in all linearization of the parents of a class, then it will also precedes class Y in the final linearization.
class A:
 pass

class B(A):
 pass

class D(B, A):
 pass

d = D()
d.__mro__ # D, B, A

Example from Python Cookbook