<div dir="ltr"><div class="gmail_default" style="font-family:tahoma,sans-serif;color:#000000">Dear all,</div><div class="gmail_default" style="font-family:tahoma,sans-serif;color:#000000"><br></div><div class="gmail_default" style="font-family:tahoma,sans-serif;color:#000000">this is a highly sensitive topic, isn't it? =) Thank you all for your extensive responses. Of course I was a bit provocative with the sentence in bold, but I haven't said this would be a bug, and if I have, I am sorry for that.</div><div class="gmail_default" style="font-family:tahoma,sans-serif;color:#000000"><br></div><div class="gmail_default" style="font-family:tahoma,sans-serif;color:#000000">I am in fact not familiar with what precisely are all the problems the C3 algorithm tries to solve, however my own intuitiv MRO would not be anything proposed so far, but:</div><div class="gmail_default" style="font-family:tahoma,sans-serif;color:#000000"><br></div><div class="gmail_default" style="font-family:tahoma,sans-serif;color:#000000">(B, mixin, A, mixin, object)</div><div class="gmail_default" style="font-family:tahoma,sans-serif;color:#000000"><br></div><div class="gmail_default" style="font-family:tahoma,sans-serif;color:#000000">or in the simpler, more trivial version</div><div class="gmail_default" style="font-family:tahoma,sans-serif;color:#000000"><br></div><div class="gmail_default" style="font-family:tahoma,sans-serif;color:#000000">(B, object, A, object)</div><div class="gmail_default" style="font-family:tahoma,sans-serif;color:#000000"><br></div><div class="gmail_default" style="font-family:tahoma,sans-serif;color:#000000">As you haven't mentioned this as a possibility at all, I guess having a class twice in this list produces some weird behaviour I do not know about yet - if someone can point out, that would be great.</div><div class="gmail_default" style="font-family:tahoma,sans-serif;color:#000000"><br></div><div class="gmail_default" style="font-family:tahoma,sans-serif;color:#000000">cheers,</div><div class="gmail_default" style="font-family:tahoma,sans-serif;color:#000000">Stephan</div><div class="gmail_default" style="font-family:tahoma,sans-serif;color:#000000"><br></div><div class="gmail_default" style="font-family:tahoma,sans-serif;color:#000000">P.S.: I haven't said that I want a python 2.8, nevertheless thanks for pointing out that there won't be a python 2.8 (this I in fact have not known before)! I am familar with python 3.5 as well, however I just wanted to make clear where I am working and in which language the example code is runnable.</div><div class="gmail_default" style="font-family:tahoma,sans-serif;color:#000000"><br></div></div><div class="gmail_extra"><br><div class="gmail_quote">On 10 December 2015 at 19:58, Andrew Barnert <span dir="ltr"><<a href="mailto:abarnert@yahoo.com" target="_blank">abarnert@yahoo.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="auto"><span class=""><div>On Dec 10, 2015, at 08:36, Stephan Sahm <<a href="mailto:Stephan.Sahm@gmx.de" target="_blank">Stephan.Sahm@gmx.de</a>> wrote:</div><div><br></div><blockquote type="cite"><div><div dir="ltr"><div class="gmail_default" style="font-family:tahoma,sans-serif;color:rgb(0,0,0)">Dear all,</div><div class="gmail_default" style="font-family:tahoma,sans-serif;color:rgb(0,0,0)"><br></div><div class="gmail_default" style="font-family:tahoma,sans-serif;color:rgb(0,0,0)">I just pushed a very specific question which as I now recognized is far more general: It concerns python MRO (method resolution order).</div><div class="gmail_default" style="font-family:tahoma,sans-serif;color:rgb(0,0,0)"><br></div><div class="gmail_default" style="font-family:tahoma,sans-serif;color:rgb(0,0,0)">As reference I take <a href="https://www.python.org/download/releases/2.3/mro/" target="_blank">https://www.python.org/download/releases/2.3/mro/</a></div><div class="gmail_default"><font color="#000000" face="tahoma, sans-serif">There the section "</font>Bad Method Resolution Orders" starts with an example which behaviour in the current python 2.7 is rather unintuitive to me.</div></div></div></blockquote><div><br></div></span><div>First off, Python 2.7 isn't going to change, and there isn't going to be a 2.8. If you want to propose changes to Python, you first need to learn what's changed up to 3.5, and then propose your change for 3.6.</div><div><br></div><div>Second, the fact that it's unintuitive may be a problem with the description, rather than the algorithm. Once you understand what it's trying to do, and what you're trying to do, and why they're not compatible, it's intuitive that it doesn't work. Maybe the docs need to make it easier to understand what it's trying to do, and maybe you can help point out what's confusing you.</div><div><br></div><div>Since Python just borrowed the C3 algorithm from Dylan to solve the same problems, and other languages have borrowed it as well, you might want to search for more generic documentation on it, too.</div><div><br></div><div>Anyway, if you understand what C3 is solving, and you think it could be modified to still solve those problems while also allowing your use, or that one of those problems can't be solved but you don't think it's actually a problem, then explain that. Otherwise, I think you're either asking for something inconsistent, or asking for something consistent but broken, like the C++ rules (which would be even more broken in Python without first adding notions like virtual base class and auto-pre-supering constructors).</div><div><div class="h5"><div><br></div><blockquote type="cite"><div><div dir="ltr"><div class="gmail_default">I rename the example slightly to illustrate its usecase.</div><div class="gmail_default"><br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">class Mixin(object):<br>  pass  </blockquote><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">class A(Mixin):<br>  pass<br>class B(Mixin, A):<br>  pass</blockquote><div class="gmail_default"><br></div><div class="gmail_default">this unfortunately throws "TypeError: Error when calling the metaclass bases Cannot create a consistent method resolution order (MRO) for bases A, Mixin"</div><div class="gmail_default"><span style="color:rgb(0,0,0);font-family:tahoma,sans-serif;font-size:14px;line-height:17.0001px;white-space:pre-wrap"><br></span></div><div class="gmail_default"><span style="color:rgb(0,0,0);font-family:tahoma,sans-serif;font-size:14px;line-height:17.0001px;white-space:pre-wrap"><br></span></div><div class="gmail_default"><span style="color:rgb(0,0,0);font-family:tahoma,sans-serif;font-size:14px;line-height:17.0001px;white-space:pre-wrap">The reference name above​ comments this case similar to the following (adapted to the easier example above):</span></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">We see that class <div class="gmail_default" style="font-family:tahoma,sans-serif;color:rgb(0,0,0);display:inline">​B​</div> inherits from <div class="gmail_default" style="font-family:tahoma,sans-serif;color:rgb(0,0,0);display:inline">​Mixin​</div> and <div class="gmail_default" style="font-family:tahoma,sans-serif;color:rgb(0,0,0);display:inline">​A​</div>, with <div class="gmail_default" style="font-family:tahoma,sans-serif;color:rgb(0,0,0);display:inline">​Mixin</div> before <div class="gmail_default" style="font-family:tahoma,sans-serif;color:rgb(0,0,0);display:inline">​A​</div>: therefore we would expect attribute<div class="gmail_default" style="font-family:tahoma,sans-serif;color:rgb(0,0,0);display:inline">​s of ​</div><div class="gmail_default" style="font-family:tahoma,sans-serif;color:rgb(0,0,0);display:inline">​B</div> to be inherited<div class="gmail_default" style="font-family:tahoma,sans-serif;color:rgb(0,0,0);display:inline">​ first​</div> by <div class="gmail_default" style="font-family:tahoma,sans-serif;color:rgb(0,0,0);display:inline">​Mixin</div> and <div class="gmail_default" style="font-family:tahoma,sans-serif;color:rgb(0,0,0);display:inline">​then​ </div>by <div class="gmail_default" style="font-family:tahoma,sans-serif;color:rgb(0,0,0);display:inline">​A</div>: nevertheless Python 2.2 <div class="gmail_default" style="font-family:tahoma,sans-serif;color:rgb(0,0,0);display:inline">​was giving the opposite behaviour.</div></blockquote><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">​...<br>As a general rule, hierarchies such as the previous one should be avoided, since it is unclear if <div class="gmail_default" style="font-family:tahoma,sans-serif;color:rgb(0,0,0);display:inline">​Mixin</div> should override <div class="gmail_default" style="font-family:tahoma,sans-serif;color:rgb(0,0,0);display:inline">​A​</div> or viceversa<font color="#000000" face="tahoma, sans-serif">​</font></blockquote> <div><div class="gmail_default" style="font-family:tahoma,sans-serif;color:rgb(0,0,0)"><br></div><div class="gmail_default" style="font-family:tahoma,sans-serif;color:rgb(0,0,0)">​While it might be the case that in Python​ 2.2 things where different, I cannot agree that the expected order of Method resolution is ambiguous (at least as far I see at this stage). </div></div></div></div></blockquote><div><br></div></div></div><div>Mixin has to appear before A so that its methods appear before A's. But Mixin has to appear between A and object so that A's methods can count on inheriting from it. How do you fit both those constraints?</div><span class=""><br><blockquote type="cite"><div><div dir="ltr"><div><div class="gmail_default" style="font-family:tahoma,sans-serif;color:rgb(0,0,0)">The reference itself says that we would expect <div class="gmail_default" style="display:inline">B</div><span style="font-family:arial,sans-serif;color:rgb(34,34,34)"> to be inherited</span><div class="gmail_default" style="display:inline">​ first​</div><span style="font-family:arial,sans-serif;color:rgb(34,34,34)"> </span><span style="font-family:arial,sans-serif;color:rgb(34,34,34)">by</span><span style="font-family:arial,sans-serif;color:rgb(34,34,34)"> </span><div class="gmail_default" style="display:inline">​Mixin</div><span style="font-family:arial,sans-serif;color:rgb(34,34,34)"> and</span><span style="font-family:arial,sans-serif;color:rgb(34,34,34)"> </span><div class="gmail_default" style="display:inline">​then​ </div><span style="font-family:arial,sans-serif;color:rgb(34,34,34)">by</span><span style="font-family:arial,sans-serif;color:rgb(34,34,34)"> </span><div class="gmail_default" style="display:inline">​A. There is no ambiguity any longer.</div></div></div></div></div></blockquote><blockquote type="cite"><div><div dir="ltr"><div><div class="gmail_default" style="font-family:tahoma,sans-serif;color:rgb(0,0,0)"><div class="gmail_default" style="display:inline"><br></div></div><div class="gmail_default" style="font-family:tahoma,sans-serif;color:rgb(0,0,0)"><div class="gmail_default" style="display:inline"><b>Therefore I would like to propose to make this MRO again a valid one.</b></div></div><div class="gmail_default" style="font-family:tahoma,sans-serif;color:rgb(0,0,0)"><div class="gmail_default" style="display:inline"><br></div></div><div class="gmail_default" style="font-family:tahoma,sans-serif;color:rgb(0,0,0)"><div class="gmail_default" style="display:inline"><br></div></div><div class="gmail_default" style="font-family:tahoma,sans-serif;color:rgb(0,0,0)"><div class="gmail_default" style="display:inline">The usecase should be obvious: If you want a Mixin to be the first thing overwriting functions, but still want to inherit as normal.</div></div></div></div></div></blockquote><div><br></div></span><div>That's not what mixins are for. Mixins add behavior; something that changes the behavior of a real superclass is something different.</div><span class=""><br><blockquote type="cite"><div><div dir="ltr"><div><div class="gmail_default" style="font-family:tahoma,sans-serif;color:rgb(0,0,0)"><div class="gmail_default" style="display:inline">(I myself want for instance a Mixin to overwrite the __init__ method, which is simply not impossible when choosing class B(A, Mixin))</div></div><br></div><div><br></div><div class="gmail_default">best,</div><div class="gmail_default">Stephan</div><div class="gmail_default" style="font-family:tahoma,sans-serif;color:rgb(0,0,0)"><br></div><div class="gmail_default" style="font-family:tahoma,sans-serif;color:rgb(0,0,0)"><br></div><div class="gmail_default" style="font-family:tahoma,sans-serif;color:rgb(0,0,0)"><br></div></div>
</div></blockquote></span><span class=""><blockquote type="cite"><div><span>_______________________________________________</span><br><span>Python-ideas mailing list</span><br><span><a href="mailto:Python-ideas@python.org" target="_blank">Python-ideas@python.org</a></span><br><span><a href="https://mail.python.org/mailman/listinfo/python-ideas" target="_blank">https://mail.python.org/mailman/listinfo/python-ideas</a></span><br><span>Code of Conduct: <a href="http://python.org/psf/codeofconduct/" target="_blank">http://python.org/psf/codeofconduct/</a></span></div></blockquote></span></div></blockquote></div><br></div>