Skip to content

Instantly share code, notes, and snippets.

@arthurio
Created March 11, 2014 00:19
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 arthurio/9477185 to your computer and use it in GitHub Desktop.
Save arthurio/9477185 to your computer and use it in GitHub Desktop.
Build a dict in python - 2.6 syntax vs. 2.7
data = ['a', 'b', 'c']
# Python v2.7
my_dict = {key: i for i, key in enumerate(data)}
# Python v2.6
my_dict = dict((key, i) for i, key in enumerate(data))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment