Python Constructor Overriding

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 .

Constructor Overriding Example

CopiedCopy Code

class Father: 
   def __init__(self): = 800000.00 
   def display_property(self): 
      print('Father\'s property=', 
class Son(Father): 
   def __init__(self): = 200000.00 
   def display_property(self): 
      print('Child\'s property=', 
s = Son() 

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.