python 类多重继承问题

# _*_ coding: utf-8 _*_
__author__ = 'pythonwu'
__date__ = "2018/7/2 14:50"

class A():
def getValue(self):
print('return value of A ')

def show(self):
print('I can show A')


class B(A):
def getValue(self):
print('return value of B')

class C(A):
def getValue(self):
print('return value of C')

def show(self):
print('I can show C')


class D(B,C):
pass

d = D()
d.show()
d.getValue()

from pprint import pprint
pprint(D.mro())

I can show C
return value of B
[<class '__main__.D'>,
<class '__main__.B'>,
<class '__main__.C'>,
<class '__main__.A'>,
<class 'object'>]

posted @ 2018-07-02 15:52  五等码农  阅读(189)  评论(0编辑  收藏  举报