A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://mail.python.org/pipermail/python-dev/2003-December/040647.html below:

[Python-Dev] Re: "groupby" iterator

[Python-Dev] Re: "groupby" iterator [Python-Dev] Re: "groupby" iteratorRaymond Hettinger python at rcn.com
Wed Dec 3 10:27:49 EST 2003
> (This thread has nothing to do with the groupby iterator any more, but
> I'm loathe to change the subject since so many messages are already
> under this one.)
> 
> (I've read quite a few messages posted after Greg's post, but Greg
> still summarizes the issue best for me, *and* it has an alternative
> idea that needs a response.)

I'm am still curious to hear your thoughts on the either sublime or
crazy idea for a generalized extractor object:

list.sorted(students, key=extract.score)
list.sorted(animal_weights, key=extract[1])
groupby(students, key=extract.homeroom)
groupby(recordtuples, key=extract[0])



Raymond Hettinger



P.S.  The implementation code is very simple:

class ExtractorClass(object):
    def __getattribute__(self, attr):
        return operator.attrgetter(attr)
    def __getitem__(self, key):
        return operator.itemgetter(key)

extract = ExtractorClass()


More information about the Python-Dev mailing list

RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4