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