Skip to content

Instantly share code, notes, and snippets.

@colbypalmer
Created February 5, 2015 22:50
Show Gist options
  • Save colbypalmer/9135a6059a4c5f474062 to your computer and use it in GitHub Desktop.
Save colbypalmer/9135a6059a4c5f474062 to your computer and use it in GitHub Desktop.
Traverse an array by pairs
# Used this to turn a 2-column spreadsheet to json key-value pairs
def traversebypairs(iterable):
a = iter(iterable)
return izip(a,a)
for a, b in traversebypairs(list):
print u'{{"{}", "{}"}},'.format(a, b)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment