Skip to content

Instantly share code, notes, and snippets.

@jeepkd
Last active September 18, 2017 14:34
Show Gist options
  • Save jeepkd/f9cb4d561970a58925997841eeff9ffc to your computer and use it in GitHub Desktop.
Save jeepkd/f9cb4d561970a58925997841eeff9ffc to your computer and use it in GitHub Desktop.
def grouper(n, iterable):
it = iter(iterable)
while True:
chunk = tuple(itertools.islice(it, n))
if not chunk:
return
yield chunk
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment