MRO stands for Method Resolution Order. MRO denotes the way a programming language resolves a method or attribute.
In Python, a class can inherit features and attributes from multiple classes and thus, multiple inheritance is implemented. MRO is the hierarchy in which base classes are searched when looking for a method in the parent class. First, the method or attribute is searched within a class and then it follows the order we specified while inheriting.
#mro example class A: def func(self): print("In Class A") class B(A): def func(self): print("In Class B") t = B() t.func()
In Class B
In the above example the methods that are invoked are from class B but not from class A, and this is due to Method Resolution Order(MRO).
The order that follows in the above code is
class B -> class A
In multiple inheritances, the methods are executed based on the order specified while inheriting the classes.