我有3类A,B和d给出如下Python的多重继承
class A(object):
def test(self):
print "called A"
class B(object):
def test(self):
print "called B"
class D(A,B):
def test(self):
super(A,self).test()
inst_d=D()
inst_d.test()
----------------------------------------
Output:
called B
问题:D.test()
,我打电话super(A,self).test()
。即使方法A.test()
也存在,为什么只调用B.test()
?
方式Python的超级作品有些不明显。如何正确使用它具有很大的实用指南是这个:http://rhettinger.wordpress.com/2011/05/26/super-considered-super/ – millimoose 2012-07-18 18:18:20