python / psf-infra-meta

Meta-repository for PSF backed or managed systems. Created mainly for the issue tracker :)
10 stars 9 forks source link

多重继承问题:super中传一个多重继承的类,只能识别到第一个 #139

Closed ipmshen closed 2 years ago

ipmshen commented 2 years ago

问题描述: 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)

matrixise commented 2 years ago

Sorry, but this tracker is not for Python itself. Please use the right Mailing list for that. https://discuss.python.org/