Skip to content

Instantly share code, notes, and snippets.

@palawer
Created April 22, 2020 12:15
Show Gist options
  • Save palawer/c51291792b379050b147715244656cec to your computer and use it in GitHub Desktop.
Save palawer/c51291792b379050b147715244656cec to your computer and use it in GitHub Desktop.
from itertools import zip_longest
def grouper(iterable, n=1000, fillvalue=None):
args = [iter(iterable)] * n
return zip_longest(*args, fillvalue=fillvalue)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment