Python Constructors and Methods

When the programmer writes a constructor in the sub class, the super class constructor is not available to the sub class. In this case, only the sub class constructor is accessible from the sub class object. That means the sub class constructor is replacing the super class constructor. This is called constructor overriding. Similarly in the sub class, if we write a method with exactly same name as that of super class method, it will override the super class method. This is called method overriding.


A Python program to override super class constructor and method in sub class.


In this case, how to call the super class constructor so that we can access the father's property from the Son class? For this purpose, we should call the constructor of the super class from the constructor of the sub class using the super() method.