Skip to content

Instantly share code, notes, and snippets.

@gonz
Created December 17, 2013 17:12
Show Gist options
  • Save gonz/8008641 to your computer and use it in GitHub Desktop.
Save gonz/8008641 to your computer and use it in GitHub Desktop.
iterator split_every
def split_every(n, iterable):
i = iter(iterable)
piece = list(islice(i, n))
while piece:
yield piece
piece = list(islice(i, n))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment