89.子类调用父类同名属性和方法

# 古法师傅类
class Master(object):

    def __init__(self):
        self.kongfu1 = "古法配方"

# 现代师傅类
class School(object):

    def __init__(self):
        self.kongfu2 = "现代配方"


# 徒弟类(古法配方, 现代配方, 猫式配方)
class Prentice(Master, School):

    def __init__(self):
        Master.__init__(self)
        School.__init__(self)
        self.kongfu3 = "猫式配方"


dm = Prentice()
print(dm.kongfu3)
print(dm.kongfu2)
print(dm.kongfu1)

 

posted @ 2020-05-11 20:35  kelin1  阅读(233)  评论(0编辑  收藏  举报