Overriding methods inherited from a superclass with methods from a mixin
greg.ewing at canterbury.ac.nz
Mon Jun 13 18:28:51 EDT 2016
alanqueiros at gmail.com wrote:
> I see that in most cases the order doesn't matter, but still I would
> think that since the correct order is from right to left, that should be the
> common practice.
This order is only "correct" if overriding is what you want.
That's not always going to be the case. The mixin might be
intended to supply default functionality that can be
overridden by the classes it's being mixed into. You
can't say that one order is more correct than the other
> Basically, I
> think of the mixins like plugins of kinds, I'm "adding" functionality to that
> "base" class I'm inheriting from. Having them to the left sounds like a
> sandwich recipe that tells you to "slice the ham, put mayonnaise on it, and
> put it on the bread".
To me it's more like adding seasoning to a dish. Normally
you put the main ingredient in first, then add the salt
and pepper. This is probably the way most people are
thinking when they write the mixins after the main base
More information about the Python-list