This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author Isaac Morland
Recipients Isaac Morland
Date 2017-07-31.01:21:23
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1501464083.62.0.710684821005.issue31086@psf.upfronthosting.co.za>
In-reply-to
Content
Here is the diff.  Note that I assume implementation of #31085, which allows me to push determination of a name for the namedtuple down into namedtuple itself:

diff --git a/Lib/collections/__init__.py b/Lib/collections/__init__.py
index 62cf708..d507d23 100644
--- a/Lib/collections/__init__.py
+++ b/Lib/collections/__init__.py
@@ -14,7 +14,8 @@ list, set, and tuple.
 
 '''
 
-__all__ = ['deque', 'defaultdict', 'namedtuple', 'UserDict', 'UserList',
+__all__ = ['deque', 'defaultdict', 'namedtuple', 'namedattrgetter',
+            'UserDict', 'UserList',
             'UserString', 'Counter', 'OrderedDict', 'ChainMap']
 
 # For backwards compatibility, continue to make the collections ABCs
@@ -23,7 +24,7 @@ from _collections_abc import *
 import _collections_abc
 __all__ += _collections_abc.__all__
 
-from operator import itemgetter as _itemgetter, eq as _eq
+from operator import itemgetter as _itemgetter, attrgetter as _attrgetter, eq as _eq
 from keyword import iskeyword as _iskeyword
 import sys as _sys
 import heapq as _heapq
@@ -451,6 +452,14 @@ def namedtuple(typename, field_names, *, verbose=False, rename=False, module=Non
 
     return result
 
+def namedattrgetter (attr, *attrs):
+    ag = _attrgetter (attr, *attrs)
+
+    if attrs:
+        nt = namedtuple (None, (attr,) + attrs, rename=True)
+        return lambda obj: nt._make (ag (obj))
+    else:
+        return ag
 
 ########################################################################
 ###  Counter
History
Date User Action Args
2017-07-31 01:21:23Isaac Morlandsetrecipients: + Isaac Morland
2017-07-31 01:21:23Isaac Morlandsetmessageid: <1501464083.62.0.710684821005.issue31086@psf.upfronthosting.co.za>
2017-07-31 01:21:23Isaac Morlandlinkissue31086 messages
2017-07-31 01:21:23Isaac Morlandcreate