如果我定义了一个父类和子类,如下所示:“A”不能访问方法的超类
class A(object):
def a_method(self):
print "A!"
class B(A):
def b_method(self):
super(A, self).a_method()
print "B!"
b_obj = B()
我希望下面的打印出来和“B!”,但它会抛出一个错误:
b_obj = B()
AttributeError: 'super' object has no attribute 'a_method'
我很困惑。我错过了什么?
标志着我你的答案是正确的,因为你也提到的MRO,它回答了相关的问题我有。谢谢。 – PProteus