Skip to content

Instantly share code, notes, and snippets.

@signed0
Created February 2, 2012 22:03
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save signed0/1726072 to your computer and use it in GitHub Desktop.
Save signed0/1726072 to your computer and use it in GitHub Desktop.
Pairs Iterator
def pairs(iterable):
'''Generate pairs of items in iterable'''
i = iter(iterable)
prev = i.next()
for j in i:
yield prev, j
prev = j
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment