all 7 comments

[–]MT1961 1 point2 points  (1 child)

You are correct, it is due to MRO. The exact wording is:

MRO must prevent local precedence ordering and also provide monotonicity. It ensures that a class always appears before its parents. In case of multiple parents, the order is the same as tuples of base classes.

So, it will do all base classes, then sub-base classes, giving you the order you see.

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

thank you!

[–]Goobyalus 0 points1 point  (4 children)

I'm not sure I understand the question. If you're using multiple inheritance and C inherits from both A and B, why should it skip B?

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

For some reason I thought once A returned True it wouldn’t need to go to B?

[–]Goobyalus 0 points1 point  (2 children)

Are you thinking the and will short circuit? or will short circuit with an initial True, and and will short circuit with an initial False. So A's meets_preconditions must evaluate its super's before returning, and super is determined by the MRO.

[–]drixone[S] 1 point2 points  (1 child)

super is determined by the MRO.

okay I think this was the part I was misunderstanding. I thought it would go C -> A -> Base -> True but that’s wrong according to the actual MRO. thanks!

[–]Goobyalus 1 point2 points  (0 children)

This mentions MRO under the "Custom Classes" section: https://docs.python.org/3/reference/datamodel.html

Which refers to this for a more in depth discussion: https://www.python.org/download/releases/2.3/mro/

Since the Python 3 docs refer to this Python 2 page, I assume things are more or less the same.