Created
October 19, 2011 20:16
-
-
Save ericmoritz/1299537 to your computer and use it in GitHub Desktop.
itertools plus
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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