Skip to content

Instantly share code, notes, and snippets.

@ericmoritz
Created October 19, 2011 20:16
Show Gist options
  • Save ericmoritz/1299537 to your computer and use it in GitHub Desktop.
Save ericmoritz/1299537 to your computer and use it in GitHub Desktop.
itertools plus
def ichunk(s, size):
return (s[i: i+size] for i in xrange(0, len(s), size))
def ichain(iterable):
"""Better than itertools.chain because it does not use *args"""
for inner in iterable:
for item in inner:
yield item
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment