Skip to content

Instantly share code, notes, and snippets.

@wood-push-melon
Created December 11, 2019 14:50
Show Gist options
  • Save wood-push-melon/d533c51b83c036dc86fd1ed545178962 to your computer and use it in GitHub Desktop.
Save wood-push-melon/d533c51b83c036dc86fd1ed545178962 to your computer and use it in GitHub Desktop.
Taking Slice of an Iterator
import itertools
# NOTE: this will consume all items up until the start of slice
# and also all the items in islice object
s = itertools.islice(range(50), 10, 20)
for val in s:
...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment