Example Call Parent Class Constructor from Child Class in Python
In this type of inheritance parent class attributes initialized using child class constructor.
class Family: # Parent class constructor def __init__(self, name): self.name = name # Father class inherited from Family class Father(Family): # Child class constructor def __init__(self, name, age): # Parent class constructor called from child class Family.__init__(self, name) self.age = age f = Father("Mark", 36) print(f.name) print(f.age)
2019-01-09T02:13:01+05:30
2019-01-09T02:13:01+05:30
Amit Arora
Amit Arora
Python Programming Tutorial
Python
Practical Solution