Skip to content

Instantly share code, notes, and snippets.

@lbjay
Created May 13, 2011 15:11
Show Gist options
  • Save lbjay/970705 to your computer and use it in GitHub Desktop.
Save lbjay/970705 to your computer and use it in GitHub Desktop.
return items from a list 2-at-a-time as 2-item tuples
def group(iterator, count):
itr = iter(iterator)
while True:
yield tuple([itr.next() for i in range(count)])
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment