Skip to content

Instantly share code, notes, and snippets.

@russkel
Last active January 7, 2017 04:09
Show Gist options
  • Save russkel/7788166e422a7f57039066f2c01c6d48 to your computer and use it in GitHub Desktop.
Save russkel/7788166e422a7f57039066f2c01c6d48 to your computer and use it in GitHub Desktop.
from itertools import groupby
def break_into(it, count):
def keyfunc(elem):
keyfunc.counter += 1
return (keyfunc.counter-1)//count
keyfunc.counter = 0
return (g for k, g in groupby(it, keyfunc))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment