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
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