Skip to content

Instantly share code, notes, and snippets.

@joelrebel
Created November 11, 2016 02:49
Show Gist options
  • Save joelrebel/b998fd8e56af40f2c0eb024bbed1f6df to your computer and use it in GitHub Desktop.
Save joelrebel/b998fd8e56af40f2c0eb024bbed1f6df to your computer and use it in GitHub Desktop.
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