Multiple & Multilevel Inheritance in Python
Multilevel inheritance is a chain — a class inherits from a class that itself inherits from another, several generations deep. Multiple inheritance is different — a single class inherits directly from more than one parent class at once, combining behavior from each. Python supports both, though multiple inheritance needs a clear resolution order for cases where parents define the same method.
Multilevel inheritance forms a chain
class C(B): where B is itself class B(A): — C gets access to everything both ancestors define.
Multiple inheritance combines parents directly
class C(A, B): lets C inherit from both A and B at once.
Conflicts are resolved by MRO
If both parents define the same method name, the Method Resolution Order decides which wins — generally the first-listed parent.
__mro__ shows the exact search order
ClassName.__mro__ reveals precisely how Python will look up a method or attribute.
Composition is often the simpler alternative
Once relationships get complex, many codebases prefer one class containing another instead of deep multiple inheritance.
class Flyer: def move(self): print("Flying") class Swimmer: def move(self): print("Swimming") class Duck(Flyer, Swimmer): pass d = Duck()d.move()print(Duck.__mro__)Recommended resourcesAffiliate links · may earn us a commission
Recommended for learners
Practice what you learned
Re-implement each visualized algorithm in Python yourself — building beats watching.