Skip to content

Instantly share code, notes, and snippets.

@moshekaplan
Created January 31, 2013 01:00
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save moshekaplan/4678925 to your computer and use it in GitHub Desktop.
Save moshekaplan/4678925 to your computer and use it in GitHub Desktop.
def chunks(chunkable, n):
""" Yield successive n-sized chunks from l.
"""
for i in xrange(0, len(chunkable), n):
yield chunkable[i:i+n]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment