Skip to content

Instantly share code, notes, and snippets.

@larsks
Created May 14, 2009 19:30
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save larsks/111839 to your computer and use it in GitHub Desktop.
Save larsks/111839 to your computer and use it in GitHub Desktop.
An example of using the itertools module
# 2009-05-14 13:49 < spdr-:#python> hello. is there an elegant way
# to loop for at most N iterations? for a in collection: ...
# 2009-05-14 13:49 < KirkMcDonald:#python> spdr-:
for x in itertools.islice(collection, N):
pass
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment