那个print s.skill()怎么理解,skill不是在BasketballMixin中定义的吗?s是BStudent的实例吧,怎么BStudent也有这个方法?skill究竟算不算属性?
class Person(object):
pass
class Student(Person):
pass
class Teacher(Person):
pass
class SkillMixin(object):
pass
class BasketballMixin(SkillMixin):
def skill(self):
return 'basketball'
class FootballMixin(SkillMixin):
def skill(self):
return 'football'
class BStudent(Student, BasketballMixin):
pass
class FTeacher(Teacher, FootballMixin):
pass
s = BStudent()
print s.skill()