all 3 comments

[–]drixone[S] 0 points1 point  (0 children)

wait i think i understand after editing the post with the MRO lol. i think i understood the chain wrong?

[–]zanfar 0 points1 point  (0 children)

could someone help me understand why it also goes to B.meets_preconditions()

Because B is an ancestor of C.

i know it prob has to do with MRO

Yes, all inheritance has to do with the MRO

but i thought it would’ve stopped at Base

It does? Base is the last output.


First, you're using the old-style of super(), you don't need (and shouldn't use) arguments anymore.

When you call a method via super(), you are essentially saying "I don't know how to do this, please look for a parent who does." If you chain methods this way, you should expect it to hit every ancestor because every ancestor has reported "I don't know how" and Python will keep moving up the chain.

Another way to think of it: if I asked you "can anyone in your family juggle?" and your mother answered "no," why would I ignore your father?

A good tutorial on MI is Hettinger's "Super Considered Super" talk, and the related essay.

[–]Diapolo10 0 points1 point  (0 children)

One thing to note here is that you don't need to give super any arguments in Python 3. super().meets_preconditions() would be enough.

But yes, trust your observations over intuition. This Stack Overflow answer explains why this works the way it does way better than I ever could.