On Thu, Nov 16, 2017 at 1:11 AM Greg Ewing <greg.ew...@canterbury.ac.nz> wrote:
> 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. > Interesting idea, but unfortunately, reordering base classes doesn't solve all of the problems that a precedence specification does. For example, the original example was: R < E, C B < S, E S < C Z < B, R If we make it slightly more complicated: class Y: pass class X(Y): pass class E(X): pass class C: pass class R(E, C): pass class S(C, Y): pass class B(S, E): pass class Z(B, R): pass Then, S and E can't be swapped. > > 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? > In general, I think that this would be a cool project, but is much hard than the user declaring a consistent order. > > -- > Greg > _______________________________________________ > Python-ideas mailing list > Python-ideas@python.org > https://mail.python.org/mailman/listinfo/python-ideas > Code of Conduct: http://python.org/psf/codeofconduct/ > > -- > > --- > You received this message because you are subscribed to a topic in the > Google Groups "python-ideas" group. > To unsubscribe from this topic, visit > https://groups.google.com/d/topic/python-ideas/T7YNKZmwW1c/unsubscribe. > To unsubscribe from this group and all its topics, send an email to > python-ideas+unsubscr...@googlegroups.com. > For more options, visit https://groups.google.com/d/optout. >
_______________________________________________ Python-ideas mailing list Python-ideas@python.org https://mail.python.org/mailman/listinfo/python-ideas Code of Conduct: http://python.org/psf/codeofconduct/