Skip to content

Instantly share code, notes, and snippets.

@simonw
Created March 3, 2010 16:35
Show Gist options
  • Select an option

  • Save simonw/320736 to your computer and use it in GitHub Desktop.

Select an option

Save simonw/320736 to your computer and use it in GitHub Desktop.
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