Created
November 11, 2016 02:49
-
-
Save joelrebel/b998fd8e56af40f2c0eb024bbed1f6df to your computer and use it in GitHub Desktop.
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 iter_fetch(l=[], c=5): | |
''' | |
given a list, yield c number | |
of items at a time. | |
''' | |
end=0 | |
start=0 | |
while True: | |
if (end + c) >= len(l)-1: | |
end = len(l) | |
else: | |
end += c | |
yield l[start:end] | |
if end >= len(l): | |
break | |
else: | |
start = end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment