0
このコードスニペットを理解できません。python継承とスーパーキーワード
class First():
def __init__(self):
super(First, self).__init__()
print("first")
class Second():
def __init__(self):
super(Second, self).__init__()
print("second")
class Third(Second, First):
def __init__(self):
super(Third, self).__init__()
print("third")
Third();
、出力は次のとおりです。
first
second
third
super(Third, self).__init__()
この文が働いているどのようにSecond.__init__()
その後、基底クラスFirst.__init__()
の逆の順序でそれぞれのコンストラクタが呼び出されるようです。