如果我定義了一個父類和子類,如下所示:「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