A RetroSearch Logo

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

Search Query:

Showing content from http://mail.python.org/pipermail/python-dev/2004-June/045420.html below:

[Python-Dev] Candidate Itertools

[Python-Dev] Candidate ItertoolsMichael Hudson mwh at python.net
Thu Jun 17 05:15:39 EDT 2004
"Raymond Hettinger" <raymond.hettinger at verizon.net> writes:

> Feedback is requested for two prospective itertools:
>
> def count_elements(iterable):
>     b = {}
>     for elem in iterable:
>         b[elem] = b.get(elem, 0) + 1
>     return ((cnt, elem) for elem, cnt in b.iteritems())

Mmm, possibly.  I've written this farily often.  As other said, I
think I'd prefer the dict.

> def pairswap(iterable):
>     return ((b,a) for a,b in iterable)

What's the point?  It's so short as a genxp...

Cheers,
mwh

-- 
  "Also, does the simple algorithm you used in Cyclops have a name?"
  "Not officially, but it answers to "hey, dumb-ass!"
                       -- Neil Schemenauer and Tim Peters, 23 Feb 2001

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