Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Does python have a non-lazy version of itertools.groupby?

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?

like image 204
dvogel Avatar asked Nov 06 '22 11:11

dvogel


1 Answers

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

like image 70
Will McCutchen Avatar answered Nov 11 '22 03:11

Will McCutchen