Last active
August 29, 2015 13:56
-
-
Save satishgoda/9142201 to your computer and use it in GitHub Desktop.
python dict fail
This file contains hidden or 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
| def foo(): | |
| l = [] | |
| return l[:] | |
| #attr_map = dict.fromkeys(prefixes_unique, foo()) | |
| attr_map = dict.fromkeys(prefixes_unique, []) | |
| for key in attr_map: | |
| print(key, id(attr_map[key])) |
This file contains hidden or 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
| attr_map = dict(map(lambda prefix: (prefix, []), prefixes_unique)) | |
| for key in attr_map: | |
| print(key, id(attr_map[key])) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment