Действительно ли super () принимает аргументы в моем случае? - PullRequest
0 голосов
/ 19 апреля 2020

Я получаю следующую ошибку в своем коде:

     Traceback (most recent call last):
 File "D:\.py prcatice\OOP Python Corey.py", line 44, in <module>
 dev_1=Developer('Executive', 'Diary', 100000, 'c++')
 File "D:\.py prcatice\OOP Python Corey.py", line 36, in __init__
 super().__init__(first,last,pay)
 TypeError: super() takes at least 1 argument (0 given)
 [Finished in 0.1s]

Я получил этот код с Youtube-канала Кори Шефера, но он не получает ошибку. Мы оба используем редактор кода Sublime Text, но ошибка по-прежнему происходит.

class Employee:

    bonus=1.04
    no_of_employees=0

    def __init__(self,first,last,pay):
        self.first=first
        self.last=last
        self.pay=pay
        Employee.no_of_employees+=1

    def enqname(self):
        print("{} {}" .format(self.first, self.last))   

    def pujorbonus(self):
        self.pay=int(self.pay*Employee.bonus)

    @classmethod
    def setbonus(cls, amount):
        cls.bonus=amount    

    @classmethod
    def newempstr(cls, empstr):
        first, last, pay = empstr.split('-')
        return cls(first,last,pay)

    @staticmethod
    def IsWorkday(day):
        if day.weekday()==5 or day.weekday()==6:
            return False
        else:
            return True     

class Developer(Employee):
    def __init__(self,first,last,pay,prog_lang):
        super().__init__(first,last,pay)
        self.prog_lang=prog_lang

dev_1=Developer('Executive', 'Diary', 100000, 'c++')
...