[Python-ideas] Consider (one day) adding an inheritance order class precedence mechanism

Greg Ewing greg.ewing at canterbury.ac.nz
Thu Nov 16 01:10:15 EST 2017


Steven D'Aprano wrote:
> These are not equivalent:
> 
> B < S, E
> B < E, S

Not in general, but in many cases they will be, e.g. if
E and S have no method names in common. I think the OP is
implying that his case is one of those.

Maybe what's really wanted is a way to say "B inherits from
S and E, but it doesn't care what order they go in". Then
the MRO generating algorithm could in principle swap them
if it would result in a consistent MRO.

Or maybe the MRO generator could decide for itself if the
order of two base classes can be swapped by inspecting
their attributes to see if any of them clash?

-- 
Greg


More information about the Python-ideas mailing list