<div dir="ltr"><br><br><div class="gmail_quote"><div dir="ltr">On Thu, Nov 16, 2017 at 1:11 AM Greg Ewing <<a href="mailto:greg.ewing@canterbury.ac.nz">greg.ewing@canterbury.ac.nz</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Steven D'Aprano wrote:<br>
> These are not equivalent:<br>
><br>
> B < S, E<br>
> B < E, S<br>
<br>
Not in general, but in many cases they will be, e.g. if<br>
E and S have no method names in common. I think the OP is<br>
implying that his case is one of those.<br>
<br>
Maybe what's really wanted is a way to say "B inherits from<br>
S and E, but it doesn't care what order they go in". Then<br>
the MRO generating algorithm could in principle swap them<br>
if it would result in a consistent MRO.<br></blockquote><div><br></div><div>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:</div><div><br></div><div><div style="color:rgb(33,33,33);font-size:13px">R < E, C</div><div style="color:rgb(33,33,33);font-size:13px">B < S, E</div><div style="color:rgb(33,33,33);font-size:13px">S < C</div><div style="color:rgb(33,33,33);font-size:13px">Z < B, R</div><div style="color:rgb(33,33,33);font-size:13px"><br></div><div style="color:rgb(33,33,33);font-size:13px">If we make it slightly more complicated:</div><div style="color:rgb(33,33,33);font-size:13px"><br></div><div style="color:rgb(33,33,33);font-size:13px"><div>class Y: pass</div><div>class X(Y): pass</div><div>class E(X): pass</div><div>class C: pass</div><div>class R(E, C): pass</div><div>class S(C, Y): pass</div><div>class B(S, E): pass</div><div>class Z(B, R): pass</div></div><div style="color:rgb(33,33,33);font-size:13px"><div><br></div><div>Then, S and E can't be swapped.</div></div></div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<br>
Or maybe the MRO generator could decide for itself if the<br>
order of two base classes can be swapped by inspecting<br>
their attributes to see if any of them clash?<br></blockquote><div><br></div><div><span style="color:rgb(33,33,33);font-size:13px">In general, I think that this would be a cool project, but is much hard than the user declaring a consistent order.</span></div><div><span style="color:rgb(33,33,33);font-size:13px">  </span> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<br>
--<br>
Greg<br>
_______________________________________________<br>
Python-ideas mailing list<br>
<a href="mailto:Python-ideas@python.org" target="_blank">Python-ideas@python.org</a><br>
<a href="https://mail.python.org/mailman/listinfo/python-ideas" rel="noreferrer" target="_blank">https://mail.python.org/mailman/listinfo/python-ideas</a><br>
Code of Conduct: <a href="http://python.org/psf/codeofconduct/" rel="noreferrer" target="_blank">http://python.org/psf/codeofconduct/</a><br>
<br>
--<br>
<br>
---<br>
You received this message because you are subscribed to a topic in the Google Groups "python-ideas" group.<br>
To unsubscribe from this topic, visit <a href="https://groups.google.com/d/topic/python-ideas/T7YNKZmwW1c/unsubscribe" rel="noreferrer" target="_blank">https://groups.google.com/d/topic/python-ideas/T7YNKZmwW1c/unsubscribe</a>.<br>
To unsubscribe from this group and all its topics, send an email to <a href="mailto:python-ideas%2Bunsubscribe@googlegroups.com" target="_blank">python-ideas+unsubscribe@googlegroups.com</a>.<br>
For more options, visit <a href="https://groups.google.com/d/optout" rel="noreferrer" target="_blank">https://groups.google.com/d/optout</a>.<br>
</blockquote></div></div>