Python Tutorial
Python - Introduction Python - Syntax Python - Variable Python - Number Python - Casting Python - String Python - Operators Python - Conditions Python - Loops Python - List Python - Tuple Python - Set Python - Dictionary Python - Function Python - Module Python - Date & Time Python - Input Output Python - Error & Exception Python - File Handling
Python OOP
OOP - Introduction OOP - Class Members OOP - Constructor Destructor OOP - Data Hiding OOP - Inheritance OOP - Overriding OOP - Overloading

Python Inheritance

Inheritance allows us to define a class in terms of another class, which makes it easier to create and maintain an application.

This also provides an opportunity to reuse the code functionality and fast implementation time.

When creating a class, instead of writing completely new data members and member functions, the programmer can designate that the new class should inherit the members of an existing class.

This existing class is called the super class or parent class, and the new class is referred to as the sub class or child class.

We can achieve inheritance using ():

How to check if a class is subclass of another?

Python provides a function issubclass() that directly tells us if a class is subclass of another class.

Multiple Inheritance

Unlike Java and like C++, Python supports multiple inheritance. We specify all parent classes as comma separated list in bracket.

The super keyword

We can access parent class members using super statement or parent class name.

Here, we called __init__ method of the Base class (from the Derived class) using super() instead of Base.__init__(self).

So, we do not need to specify the name of the base class if we use super().