[Python-Dev] PEP 560: bases classes (original) (raw)
Nick Coghlan ncoghlan at gmail.com
Wed Nov 15 10:37:06 EST 2017
- Previous message (by thread): [Python-Dev] PEP 560: bases classes / confusion
- Next message (by thread): [Python-Dev] PEP 560: bases classes / confusion
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
On 16 November 2017 at 00:20, Jim J. Jewett <jimjjewett at gmail.com> wrote:
I think the following will happen:
"NewList[int]" will be evaluated, and classgetitem called, so that the bases tuple will be (A, GenericAlias(NewList, int), B) # (A) I think mroentries 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 = mroentries(A, GenericAlias(NewList, int), B) # (C) I think mroentries 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
Cheers, Nick.
-- Nick Coghlan | ncoghlan at gmail.com | Brisbane, Australia -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://mail.python.org/pipermail/python-dev/attachments/20171116/ea076aaa/attachment.html>
- Previous message (by thread): [Python-Dev] PEP 560: bases classes / confusion
- Next message (by thread): [Python-Dev] PEP 560: bases classes / confusion
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]