Skip to content

Instantly share code, notes, and snippets.

@temoto
Forked from kmerenkov/chunkify.py
Created April 10, 2010 23:52
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save temoto/362387 to your computer and use it in GitHub Desktop.
Save temoto/362387 to your computer and use it in GitHub Desktop.
# chunkify_list( list(xrange(1, 11), 2 ) -> ([1,2], [3,4], [5,6], [7,8], [9,10])
def chunkify_list(L, size):
while L:
chunk, L = L[:size], L[size:]
yield chunk
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment