Last active
January 7, 2017 04:09
-
-
Save russkel/7788166e422a7f57039066f2c01c6d48 to your computer and use it in GitHub Desktop.
This file contains 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
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