多重继承问题:super中传一个多重继承的类,只能识别到第一个
问题描述:
B继承A,Y继承Z,BY继承B和Y,那么BY中的super只能代表B(如果是YB则只能代表Y),希望是可以super可以代表BY,代码如下:
class SkillMixin(object):
def init(self,skillName):
self.skillName = skillName
class BasketballMixin(SkillMixin):
def init(self,skillName):
super(BasketballMixin,self).init(skillName)
class Person(object):
def init(self,name,gender):
self.name = name
self.gender = gender
class Student(Person):
def init(self,name,gender,score):
super(Student, self).init(name, gender)
self.score = score
class BasketballStudent(Student,BasketballMixin,):
def init(self,name,gender,score,skillName):
super(BasketballStudent,self).init(name,gender,score,skillName)
bs = BasketballStudent('basketboy','man',59,'basketball')
print(bs.name,bs.skillName)