<div dir="ltr"><br><br><div class="gmail_quote"><div dir="ltr">On Mon, Nov 20, 2017 at 9:34 PM Nick Coghlan <<a href="mailto:ncoghlan@gmail.com">ncoghlan@gmail.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">On 21 November 2017 at 11:09, Neil Girdhar <<a href="mailto:mistersheik@gmail.com" target="_blank">mistersheik@gmail.com</a>> wrote:<br>
><br>
> On Sat, Nov 18, 2017 at 9:29 PM Nick Coghlan <<a href="mailto:ncoghlan@gmail.com" target="_blank">ncoghlan@gmail.com</a>> wrote:<br>
>><br>
>>     >>> class C: pass<br>
>>     ...<br>
>>     >>> class S(C): pass<br>
>>     ...<br>
>>     >>> class E: pass<br>
>>     ...<br>
>>     >>> class B(S, E): pass<br>
>>     ...<br>
>>     >>> class R(E, C): pass<br>
>>     ...<br>
>>     >>> class Z(B, S, R, E, C): pass<br>
>>     ...<br>
>>     Traceback (most recent call last):<br>
>>      File "<stdin>", line 1, in <module><br>
>>     TypeError: Cannot create a consistent method resolution order<br>
>> (MRO) for bases C, E<br>
<br>
> Sorry, I wrote back too quickly.  I meant also to change B's requested MRO<br>
> to be:<br>
><br>
> (B, S, E, C)<br>
><br>
> It works with that change.<br>
<br>
Right, but once you do that, then the existing resolver is already<br>
able to handle things:<br>
<br>
    >>> class C: pass<br>
    ...<br>
    >>> class S(C): pass<br>
    ...<br>
    >>> class E: pass<br>
    ...<br>
    >>> class B(S, E, C): pass<br>
    ...<br>
    >>> class R(E, C): pass<br>
    ...<br>
    >>> class Z(B, R): pass<br>
    ...<br>
    >>><br></blockquote><div><br></div><div>Sure, but like I mentioned, that's really ugly because B doesn't care about C and shouldn't have to mention it as a base class.  This solution can quickly spiral out of control so that changes in the inheritance graph require you to hunt down extraneous base classes.</div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<br>
If you wanted to pick up cases where two classes generate inconsistent<br>
MROs that will prevent mutual subclasses (like "class B(S, E)" vs<br>
"class R(E, C)"), </blockquote><div><br></div><div>yes, exactly.</div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">that feels like a job for a type checker, since it<br>
isn't obvious whether it's the definition of B or the definition of R<br>
that should be changed to reorder their MRO.<br></blockquote><div><br></div><div>I don't know what the "type checker" means here.  I figured that the easiest user specification would be precedence relationships between classes that could be applied (in the way I described).  And I figured that that could be processed for given classes when their MRO is generated.</div><div><br></div><div>The proposal of having a custom MRO generator would also be able to solve this problem.</div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
Cheers,<br>
Nick.<br>
<br>
--<br>
Nick Coghlan   |   <a href="mailto:ncoghlan@gmail.com" target="_blank">ncoghlan@gmail.com</a>   |   Brisbane, Australia<br>
</blockquote></div></div>