How does Python's super() work with multiple inheritance?
I was looking at the above question/answers and made myself really confused
53 class First(object):
54 def __init__(self):
55 print "first"
56
57 class Second(First):
58 def __init__(self):
59 super(Second, self).__init__()
60 print "second"
61
62 class Third(First):
63 def __init__(self):
64 print "third"
65
66 class Fourth(Second, Third):
67 def __init__(self):
68 super(Fourth, self).__init__()
69 print "thats it"
Fourth()
third
second
thats it
53 class First(object):
54 def __init__(self):
55 print "first"
56
57 class Second(First):
58 def __init__(self):
59 #super(Second, self).__init__() <---- commented out
60 print "second"
61
62 class Third(First):
63 def __init__(self):
64 print "third"
65
66 class Fourth(Second, Third):
67 def __init__(self):
68 super(Fourth, self).__init__()
69 print "thats it"
Fourth()
second
thats it
Could someone explain to me what's happening behind the scene in regards to why the top prints "third"
and the bottom one doesn't?
I feel like there is some sort of order/sequence that's happening behind the scene that I am not seeing.
-- Fourth.mro
commented out super in Second
(, , , , )
super in Second
(, , , , )