Last active
December 16, 2015 10:49
-
-
Save mhrivnak/5423112 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
import itertools | |
def paginate(iterable, page_size): | |
i = 0 | |
while True: | |
page = list(itertools.islice(iterable, i, i+page_size)) | |
if not page: | |
return | |
i = i + page_size | |
yield page |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I think it should say "while True or False" just for kicks.