On Apr 25, 7:42 pm, Paul Rubin wrote:
> Raymond Hettinger writes:
> > Here's a handy utility function for you guys to play with:
> > http://code.activestate.com/recipes/577676/
>
> Cute, but why not use collections.defaultdict for the return dict?
> Untested:
My first draft had a defaultdict
On Mon, 25 Apr 2011 16:48:42 -0700, Raymond Hettinger wrote:
> Here's a handy utility function for you guys to play with:
>
> http://code.activestate.com/recipes/577676/
Nice.
That's similar to itertools.groupby except that it consolidates all the
equal key results into one list, instead
Raymond Hettinger writes:
> Here's a handy utility function for you guys to play with:
> http://code.activestate.com/recipes/577676/
Cute, but why not use collections.defaultdict for the return dict?
Untested:
d = defaultdict(list)
for key,value in ifilter(bool,imap(mapper, data)):
Here's a handy utility function for you guys to play with:
http://code.activestate.com/recipes/577676/
Raymond
twitter: @raymondh
--
http://mail.python.org/mailman/listinfo/python-list