[Baypiggies] Question on Python's MRO...

Guido van Rossum guido at python.org
Wed Jan 4 22:53:41 EST 2017

On Wed, Jan 4, 2017 at 11:33 AM, Braun Brelin <bbrelin at gmail.com> wrote:

> The point here is 'which' foo is being called.  Since it seems to go from
> right to left, it finds mixin2's foo method first, and then when it finds
> mixin1's foo method second that becomes the one that is used...

This clarifies the misunderstanding. The example you gave (where
"mixin1.foo()" got called -- we all agree on that!) is clearly
left-to-right for everyone here, but you cited it as proof that the
algorithm is right-to-left. You seem to interpret the algorithm as going
from right to left and then using the *last* one found. But the way the
algorithm is normally described (not to mention how it's implemented :-) is
that it goes from left to right and stops at the *first*  one found.

Hope this help!

(If you can find a website that claims it's right-to-left I'd like to see a
link to that -- I've never seen it described that way before, and I've seen
a lot of tutorials about Python's MRO... :-)

--Guido van Rossum (python.org/~guido)
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/baypiggies/attachments/20170104/b9640175/attachment.html>

More information about the Baypiggies mailing list