views:

63

answers:

2

I don't need the laziness of itertools.groupby. I just want to group my list into a dict of lists as such:

dict([(a, list(b)) for a,b in itertools.groupby(mylist, mykeyfunc)])

Is there a standard function that already does this?

A: 

It sounds like you have a one-line function already that does what you want. Use it.

Ned Batchelder
My question is not "how do I do this?" I am seeking to avoid reimplementing a standard function.
+2  A: 

No, there's not a function included in the standard library to do this.

Will McCutchen
+1 This addresses the question exactly
gnibbler