Skip to content

Instantly share code, notes, and snippets.

@kennethzfeng
Created October 1, 2014 15:47
Show Gist options
  • Select an option

  • Save kennethzfeng/d0f3b950f337c082c63d to your computer and use it in GitHub Desktop.

Select an option

Save kennethzfeng/d0f3b950f337c082c63d to your computer and use it in GitHub Desktop.
Python Tips
# http://stackoverflow.com/questions/312443/how-do-you-split-a-list-into-evenly-sized-chunks-in-python
def chunks(l, n):
""" Yield successive n-sized chunks from l."""
for i in xrange(0, len(l), n):
yield l[i:i+n]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment