Skip to content

Instantly share code, notes, and snippets.

@satishgoda
Last active August 29, 2015 13:56
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 satishgoda/9142201 to your computer and use it in GitHub Desktop.
Save satishgoda/9142201 to your computer and use it in GitHub Desktop.
python dict fail
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]))
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