码迷,mamicode.com
首页 > 编程语言 > 详细

python 类多重继承问题

时间:2018-07-02 16:17:06      阅读:199      评论:0      收藏:0      [点我收藏+]

标签:elf   问题   odi   auth   val   date   import   .sh   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‘>]

python 类多重继承问题

标签:elf   问题   odi   auth   val   date   import   .sh   python 类   

原文地址:https://www.cnblogs.com/wudeng/p/9254201.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!