September 2026
1051 pages
35h 4m
English
Up to this point, the examples have always let a subclass inherit from exactly one base class. However, there are situations in which a class should inherit the capabilities of two or even more base classes to achieve the desired result. This concept, in which a class inherits from multiple base classes, is referred to as multiple inheritance.
If you want a class to inherit from multiple base classes, you can write the base classes separated by commas in the parentheses after the class name:
class NewClass(BaseClass1, BaseClass2, BaseClass3): # Definition of methods and attributes pass
In this example, the NewClass class inherits from three classes: BaseClass1, BaseClass2, and BaseClass3.
Multiple inheritance is ...
Read now
Unlock full access