[issue31086] Add namedattrgetter function which acts like attrgetter but uses namedtuple

Raymond Hettinger report at bugs.python.org
Mon Jul 31 05:23:02 EDT 2017


Raymond Hettinger added the comment:

The principal use case for attrgetter() was to work with key-functions for sorted/min/max/groupby/nsmallest/nlargest.  Secondarily, it worked nicely with map() and filter() as a field extractor in a chain of iterators.  Neither these use cases would benefit from creating a namedtuple.

What are your use cases that are creating a need for a variant of attrgetter that returns namedtuples?

Also, how would this be useful with rename=True?  The user of the result wouldn't know the fields names in advance and hence wouldn't be able to access them.

Do you know of any cases where someone has used this recipe is real code?  Has it been tried out on users other than yourself?

----------
assignee:  -> rhettinger
nosy: +rhettinger

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue31086>
_______________________________________


More information about the Python-bugs-list mailing list