0Pricing
Python Academy · Lesson

Multiple Inheritance and MRO

Understand multiple inheritance and Python's MRO (C3 linearization).

Introduction

Python supports multiple inheritance. The Method Resolution Order (MRO) defines which method is called when names clash.

Multiple Inheritance Syntax

class C(A, B): inherits from both A and B. C gets all methods from both.
class A:
    def hello(self): return 'A'
class B:
    def world(self): return 'B'
class C(A, B): pass
c = C()
print(c.hello(), c.world())

All lessons in this course

  1. Single Inheritance
  2. Method Overriding and super()
  3. Multiple Inheritance and MRO
  4. Polymorphism and Duck Typing
← Back to Python Academy