Answers for "how to call super class constructor in python 2.7"

2

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
Posted by: Guest on April-05-2021
0

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

# Here we declare that the Square class inherits from the Rectangle class
class Square(Rectangle):
    def __init__(self, length):
        super().__init__(length, length)
Posted by: Guest on October-18-2020

Code answers related to "how to call super class constructor in python 2.7"

Python Answers by Framework

Browse Popular Code Answers by Language