Created
October 13, 2016 12:02
-
-
Save amka/dae2defe0d78e48132168343d35fa6d1 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 get_chunk(sequence, chunk_size=100, limit=None): | |
count = 0 | |
offset = 0 | |
length = len(sequence) | |
if not limit: | |
limit = length | |
while count < limit and offset < length: | |
yield sequence[offset:chunk_size + offset] | |
count += 1 | |
offset += chunk_size |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment