Python Constructors in Inheritance

In the previous python programs, we have inherited the Student class from the Teacher class. All the methods and the variables in those methods of the Teacher class (base class) are accessible to the Student class (sub class). Are the constructors of the base class accessible to the sub class or not - is the next question we will answer.

Here, we are taking a super class by the name 'Father' and derived a sub class 'Son' from it. The Father class has a constructor where a variable 'property' is declared and initialized with 800000.00. When Son is created from Father, this constructor is by default available to Son class. When we call the method of the super class using sub class object, it will display the value of the 'property' variable.

A Python program to access the base class constructor from sub class.

The conclusion is this: like the variables and methods, the constructors in the super class are also available to the sub class object by default.