Created
March 3, 2010 16:35
-
-
Save simonw/320736 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import itertools | |
| def x_at_a_time(iterator, x): | |
| def fn((item, i)): | |
| return i / x | |
| it = itertools.groupby(itertools.izip(iterator, itertools.count()), fn) | |
| for key, group in it: | |
| yield list(p[0] for p in group) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment