<div dir="ltr"><div class="gmail_default" style="font-family:monospace,monospace"><div class="gmail_default">For anyone confused about similar things, I expect you to be interested in my post on python-ideas from today:</div><div class="gmail_default"><br></div><div class="gmail_default" style="font-family:arial,sans-serif"><font face="monospace, monospace"><a href="https://mail.python.org/pipermail/python-ideas/2017-November/047896.html">https://mail.python.org/pipermail/python-ideas/2017-November/047896.html</a></font><br></div><div class="gmail_default" style="font-family:arial,sans-serif"><br></div><div class="gmail_default" style="font-family:arial,sans-serif"><font face="monospace, monospace">––Koos</font></div></div><div class="gmail_default"><font face="monospace, monospace"><br></font></div><div class="gmail_extra"><br><div class="gmail_quote">On Wed, Nov 15, 2017 at 4:20 PM, Jim J. Jewett <span dir="ltr"><<a href="mailto:jimjjewett@gmail.com" target="_blank">jimjjewett@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">(1) I found the following (particularly "bases classes") very confusing:<br>
<br>
"""<br>
If an object that is not a class object appears in the bases of a class<br>
<br>
definition, then ``__mro_entries__`` is searched on it. If found,<br>
it is called with the original tuple of bases as an argument. The result<br>
of the call must be a tuple, that is unpacked in the bases classes in place<br>
of this object. (If the tuple is empty, this means that the original bases<br>
is<br>
simply discarded.)<br>
"""<br>
<br>
Based on the following GenericAlias/NewList/Tokens example, I think I<br>
now I understand what you mean, and would have had somewhat less<br>
difficulty if it were expressed as:<br>
<br>
"""<br>
When an object that is not a class object appears in the (tuple of)<br>
bases of a class<br>
definition, then attribute ``__mro_entries__`` is searched on that<br>
non-class object. If ``__mro_entries__`` found,<br>
it is called with the entire original tuple of bases as an argument. The result<br>
of the call must be a tuple, which is unpacked and replaces only the<br>
non-class object in the tuple of bases. (If the tuple is empty, this<br>
means that the original bases<br>
is<br>
simply discarded.)<br>
"""<br>
<br>
Note that this makes some assumptions about the __mro_entries__<br>
signature that I wasn't quite sure about from the example. So<br>
building on that:<br>
<br>
class ABList(A, NewList[int], B):<br>
<br>
I *think* the following will happen:<br>
<br>
"NewList[int]" will be evaluated, and __class_getitem__ called, so<br>
that the bases tuple will be (A, GenericAlias(NewList, int), B)<br>
<br>
# (A) I *think* __mro_entries__ gets called with the full tuple,<br>
# instead of just the object it is found on.<br>
# (B) I *think* it is called on the results of evaluating<br>
# the terms within the tuple, instead of the original<br>
# string representation.<br>
_tmp = __mro_entries__(A, GenericAlias(NewList, int), B)<br>
<br>
# (C) I *think* __mro_entries__ returns a replacement for<br>
# just the single object, even though it was called on<br>
# the whole tuple, without knowing which object it<br>
# represents.<br>
bases = (A, _tmp, B)<br>
<br>
# (D) If there are two non-class objects, I *think* the<br>
# second one gets the same arguments as the first,<br>
# rather than an intermediate tuple with the first such<br>
# object already substituted out.<br>
<br>
-jJ<br>
______________________________<wbr>_________________<br>
Python-Dev mailing list<br>
<a href="mailto:Python-Dev@python.org">Python-Dev@python.org</a><br>
<a href="https://mail.python.org/mailman/listinfo/python-dev" rel="noreferrer" target="_blank">https://mail.python.org/<wbr>mailman/listinfo/python-dev</a><br>
Unsubscribe: <a href="https://mail.python.org/mailman/options/python-dev/k7hoven%40gmail.com" rel="noreferrer" target="_blank">https://mail.python.org/<wbr>mailman/options/python-dev/<wbr>k7hoven%40gmail.com</a><br>
</blockquote></div><br><br clear="all"><div><br></div>-- <br><div class="gmail_signature">+ Koos Zevenhoven + <a href="http://twitter.com/k7hoven" target="_blank">http://twitter.com/k7hoven</a> +</div>
</div></div>