在Python中,如何選擇調用哪個Parent的方法?假設我想調用父ASDF2的__init__
方法。似乎我必須指定ASDF1在超()..?如果我想打電話給ASDF3的__init__
,那麼我必須指定ASDF2?!Python的多重繼承:選擇要調用哪個super()
>>> class ASDF(ASDF1, ASDF2, ASDF3):
def __init__(self):
super(ASDF1, self).__init__()
>>> ASDF()
ASDF2's __init__ happened
>>> class ASDF(ASDF1, ASDF2, ASDF3):
def __init__(self):
super(ASDF2, self).__init__()
>>> ASDF()
ASDF3's __init__ happened
對我來說似乎是瘋狂的。我究竟做錯了什麼?