Created
March 11, 2014 00:19
-
-
Save arthurio/9477185 to your computer and use it in GitHub Desktop.
Build a dict in python - 2.6 syntax vs. 2.7
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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