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

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

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

Is there a standard feature that already does this?

+5
source share
2 answers

No, there is no function in this standard library.

+4
source

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

-2
source

All Articles