python 继承实验
来源:互联网 发布:淘宝联盟怎么操作步骤 编辑:程序博客网 时间:2024/06/05 16:51
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) passb = 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.