In Python a class can inherit from more than one class. The resulting class will have all the methods and attributes from the parent classes.

In essence, it’s called multiple inheritance because a class can inherit from multiple classes.

Related course: Complete Python Bootcamp: Go from zero to hero in Python 3

python multiple inheritance

In the example below class C inherits from both class A and class B. If an object is created with class C, it has the methods of class A,B and C.

Keep in mind that if you create an object from class A or class B, they will only have the methods and attributes of those classes.

class A:
def A(self):

class B(A):
def B(self):

class C(A,B):
def C(self):

o = C()

Visually this is what happens:

multiple inheritance

Download exercises