Table of Contents
Python supports multiple inheritance. When more than one base class defines a method, Python uses the class’s method resolution order (MRO) to decide which implementation to call. super() continues the lookup after the class containing the current method, using the MRO of the actual instance.

See how the order of bases changes a call
class Person:
def talk(self):
return 'Hello'
class LoudMixin:
def talk(self):
return super().talk().upper()
class LoudPerson(LoudMixin, Person):
pass
class QuietPerson(Person, LoudMixin):
pass
print(LoudPerson().talk()) # HELLO
print(QuietPerson().talk()) # Hello
print([cls.__name__ for cls in LoudPerson.__mro__])
# ['LoudPerson', 'LoudMixin', 'Person', 'object']
LoudPerson finds LoudMixin.talk() first. Its super().talk() finds Person.talk(). QuietPerson finds Person.talk() first; that method returns without continuing the chain.
How Python builds a consistent MRO
Python uses C3 linearization. It respects the order of direct bases and preserves the ordering constraints inherited from those bases. If two classes share a parent, that parent appears once. Python raises TypeError at class creation if it can’t satisfy the ordering constraints. See the Python MRO guide for worked hierarchies.
Debugging multiple inheritance
Inspect Class.__bases__ for the direct bases and Class.__mro__ for the full lookup order. That order explains where a method definition is found. Attribute lookup has additional rules for descriptors such as properties. If a chain is meant to run cooperatively, each participating method must accept compatible arguments and pass control along with super(). Review single inheritance and method overrides before adding more than one base.
Reader Comments 0
Sign in with email or Google to join the discussion.