1 there is an exception in the process of learning python multi-inheritance. I really don"t know what the problem is. Ask for a solution
.class People(object):
def __init__(self,name,sex):
self.name=name
self.sex=sex
class Teacher(People):
def __init__(self, name, sex, student):
super(Teacher, self).__init__(name, sex)
self.student=student
class Father(People):
def __init__(self,name,sex,child):
super(Father,self).__init__(name,sex)
self.child=child
class Disen(Father,Teacher):
def __init__(self,name,sex,child,student):
super(Disen,self).__init__(name,sex,child)
super(Disen,self).__init__(name,sex,student)
print(Disen.__mro__)
disen=Disen("disen_","male","judy","student1")
exception code
F:MypythonProjectvenvScriptspython.exe F:/MypythonProject/my_file.py class /
(< class"_ main__.Disen" >, < class"_ main__.Father" >, < class"_ main__.Teacher" >, < class"_ main__.People" >, < class" object" >)
Traceback (most recent call last):
File "F:/MypythonProject/my_file.py", line 185, in < module >
disen=Disen("disen_","male","judy","student1")
File "F:/MypythonProject/my_file.py", line 182, in init
super(Disen,self).__init__(name,sex,child)
File "F:/MypythonProject/my_file.py", line 178, in init
super(Father,self).__init__(name,sex)
TypeError: _ init__ () missing 1 required positional argument: "student"
question:
1 during debugging, when the Disen class instance executes the constructor, the constructor of the Father class is first called, but the error indicates that the Father class lacks a student attribute, which is defined in the Teacher class. I really don"t know. This should be because I can"t understand diamond inheritance. I hope God can explain the concept of diamond inheritance in combination with my error. Thank you