class parent(object):
def __init__(self):
pass
def uncle(self):
self.aunt()
def aunt(self):
print 'this is my father\'s aunt'
class child(object):
def __init__(self):
super(child, self).__init__()
pass
#def aunt(self):
# print 'this is my aunt'
class bro(child, parent):
def __init__(self):
#super(bro, self).__init__()
parent.__init__(self)
child.__init__(self)
pass
b = bro()
b.aunt()
#1.multi inherit only can be init in .__init__() way
#2.if do aunt() function, bro will choose the latest (to be overrided) to run.
python 继承实验
最新推荐文章于 2022-11-16 10:35:13 发布