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/2004-June/045397.html below:

[Python-Dev] Candidate Itertools

[Python-Dev] Candidate ItertoolsBob Ippolito bob at redivi.com
Tue Jun 15 17:44:06 EDT 2004
On Jun 15, 2004, at 4:27 AM, Raymond Hettinger wrote:

> 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())
>
>
> def pairswap(iterable):
>     return ((b,a) for a,b in iterable)

pairswap would be extremely convenient, but I'm not sure about 
count_elements.  Why not just return the dict?  Or create a bucket 
type?  Why return (cnt, elem) instead of (elem, cnt) if you have 
pairswap?

-bob

-------------- next part --------------
A non-text attachment was scrubbed...
Name: smime.p7s
Type: application/pkcs7-signature
Size: 2357 bytes
Desc: not available
Url : http://mail.python.org/pipermail/python-dev/attachments/20040615/7273208e/smime.bin
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