python的类的多继承以及调用顺序

class A(object):

    def go(self):
        print('A is go')

    def stop(self):
        print('A is stop')

    def pause(self):
        print('Not only Number')

class B(A):
    def go(self):
        super(B, self).go()
        print('B is go')

    def stop(self):
        super(B, self).stop()
        print("B is stop")

    def pause(self):
        super(B, self).pause()
        print('Not only Number')

class C(A):
    def go(self):
        super(C, self).go()
        print('C is go')

    def stop(self):
        # super(C, self).stop()
        print('C is stop')


class D(B, C):
    def go(self):
        super(D, self).go()
        print('D is go')

    def stop(self):
        super(D, self).stop()
        print('D is stop')

    def pause(self):
        print('Wait D ...')

class E(B, C):
    pass

a = A()
b = B()
c = C()
d = D()
e = E()

# a.go()  #A is go
# b.go()  #A is go B is go
# c.go()  #A is go C is go
# d.go()  #A is go C is go B is go D is go
# print('========')
# e.go()  #A is go C is go B is go

# a.stop()  # A is stop
# b.stop()  # A is stop B is stop
# c.stop()  # A is stop C is stop
# print('=-==============')
# d.stop()  # A is stop C is stop B is stop D is stop
# e.stop()  # A is stop C is stop B is stop

a.pause()  # Not only Number
print('------------------')
b.pause()  # Not only Number Not only Number
print('-------------------')
c.pause()  # Not only Number 
print('---------------')
d.pause()  # Not only Number
print('------------------')
e.pause()  # Not only Number Not only Number
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值