Parent Class#

Parent Class (Super Class or Base Class): This class allows the reuse of its public properties in another class.

Child Class#

Child Class (Sub Class or Derived Class): This class inherits or extends the superclass.

A child class has all public attributes of the parent class.

class ParentClass:
    # attributes of the parent class

class ChildClass(ParentClass):
    # attributes of the child class

Super() Function#

We use super() as opposed to self to access the parent class properties instead of the child class properties of the same name.

Types of Inheritance#

Single, Multi-level, Hierarchical, Multiple, and Hybrid

Single Inheritance#

There is only one class extending from another class.

Multiple Inheritance#

A class extends another class which itself extends another class.


A base class is extended by distinct classes depending on the requirements.

Multiple Inheritance#

A class extends or is derived from more than one base class.

class ClassName(BaseClass, AnotherBaseClass, ...):
    def method()

Advantages of Inheritance#

Reusability, code modification, extensibility and data hiding.