多重继承的调用
我在最后只运行这一句代码s = BStudent(),把后面几句都屏蔽了,然后给每一个类后面都加了个输出,运行结果发现每一个类都调用了,这样: Person Student Teacher SkillMinxin BasketballMInxin FootballMinxin BStudent FTeacher 大家知道是为什么吗?为什么Teacher和FootBall也调用了?求解释
我在最后只运行这一句代码s = BStudent(),把后面几句都屏蔽了,然后给每一个类后面都加了个输出,运行结果发现每一个类都调用了,这样: Person Student Teacher SkillMinxin BasketballMInxin FootballMinxin BStudent FTeacher 大家知道是为什么吗?为什么Teacher和FootBall也调用了?求解释
2018-03-15
class Person(object):
print 'Person'
pass
class Student(Person):
print 'Student'
pass
class Teacher(Person):
print 'Teacher'
pass
class SkillMixin(object):
print 'SkillMinxin'
pass
class BasketballMixin(SkillMixin):
print 'BasketballMInxin'
def skill(self):
return 'basketball'
class FootballMixin(SkillMixin):
print 'FootballMinxin'
def skill(self):
return 'football'
class BStudent(Student,BasketballMixin):
print 'BStudent'
pass
class FTeacher(Teacher,FootballMixin):
print 'FTeacher'
pass
s = BStudent()
#print s.skill()
#t = FTeacher()
#print t.skill()
举报