python calling super class constructor code example
Example 1: how to call super class constructor in python two classes
from Employee import Employee
from Person import Person
class Manager(Person, Employee):
def __init__(self,lname, fname, phone_number, addy, start_date, salary, department, direct_reports):
Employee.__init__(self,start_date,salary)
Person.__init__(self,lname,fname,phone_number, addy)
self.department = department
self.direct_reports = direct_reports
Example 2: using super constructor python
class Rectangle:
def __init__(self, length, width):
self.length = length
self.width = width
def area(self):
return self.length * self.width
def perimeter(self):
return 2 * self.length + 2 * self.width
class Square(Rectangle):
def __init__(self, length):
super().__init__(length, length)