class Person(object): def __init__(self,name): self.name=name def who(self): return 'I am a Person,my name is %s'%self.name class Student(Person): def __init__(self,name,score): super(Student,self).__init__(name) self.score=score def who(self): return 'I am a Student,my name is %s'%self.name class Teacher(Person): def __init__(self,name,course): super(Teacher,self).__init__(name) self.course =course def who(self): return 'I am a Teacher,my name is %s'%self.name class Work(Student,Teacher): def __init__(self,name,score,course,timetable): super(Work,self).__init__(name,score,course) self.timetable=timetable p = Person('Tim') s = Student('Bob',12, ) t = Teacher('Alice', 'English') w=Work('Herman',96,'english',22) print(w.who())
Traceback (most recent call last):
File "C:\Users\hermaniu\Desktop\test1.py", line 162, in <module>
w=Work('Herman',96,'english',22)
File "C:\Users\hermaniu\Desktop\test1.py", line 156, in __init__
super(Work,self).__init__(name,score,course)
TypeError: Student.__init__() takes 3 positional arguments but 4 were given