
Nov. 29, 2021
3:12 a.m.
On Sun, Nov 28, 2021 at 04:48:01PM -0800, Christopher Barker wrote:
One example was a proposal a while back on this list for a "groupby" in itertools (it kind of withered on the vine, like many good ideas here), I suggested that it be made comprehension friendly, and some others including the OP) didn't see the point.
How is itertools.groupby not comprehension friendly?
from itertools import groupby for key, chunk in groupby( ... (x*3 for x in [2, 4, 1, 3, 5, 0, 6]), ... lambda a: a%2): ... print(key, list(chunk)) ... 0 [6, 12] 1 [3, 9, 15] 0 [0, 18]