Re: [Python-Dev] PEP 560: bases classes / confusion

15 Nov
2017
15 Nov
'17
2:04 p.m.
On Wed, Nov 15, 2017 at 5:37 PM, Nick Coghlan ncoghlan@gmail.com wrote:
On 16 November 2017 at 00:20, Jim J. Jewett jimjjewett@gmail.com wrote:
I *think* the following will happen:
"NewList[int]" will be evaluated, and __class_getitem__ called, so
that the bases tuple will be (A, GenericAlias(NewList, int), B)
# (A) I *think* __mro_entries__ gets called with the full tuple, # instead of just the object it is found on. # (B) I *think* it is called on the results of evaluating # the terms within the tuple, instead of the original # string representation. _tmp = __mro_entries__(A, GenericAlias(NewList, int), B) # (C) I *think* __mro_entries__ returns a replacement for # just the single object, even though it was called on # the whole tuple, without knowing which object it # represents. bases = (A, _tmp, B)
My understanding of the method signature:
def __mro_entries__(self, orig_bases): ... return replacement_for_self
My assumption as to the purpose of the extra complexity was:
- given orig_bases, a method could avoid injecting bases already listed if
it wanted to
- allowing multiple items to be returned provides a way to
programmatically combine mixins without having to define a new subclass for each combination
Thanks, this might provide an answer to my question about multiple mro entries here
https://mail.python.org/pipermail/python-ideas/2017-November/047897.html%E2%...
––Koos
--
+ Koos Zevenhoven + http://twitter.com/k7hoven +
1953
Age (days ago)
1953
Last active (days ago)
0 comments
1 participants
participants (1)
-
Koos Zevenhoven