Skip to content

Instantly share code, notes, and snippets.

@sjl
Forked from inky/which is best? .py
Created November 16, 2009 20:16
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 sjl/236287 to your computer and use it in GitHub Desktop.
Save sjl/236287 to your computer and use it in GitHub Desktop.
They're completely different.
>>> x = '0123456789'
>>> a, b = [{} for _ in x], [{}] * len(x)
>>> a[0]['test'], b[0]['test'] = 1, 1
>>> p(a)
[{'test': 1}, {}, {}, {}, {}, {}, {}, {}, {}, {}]
>>> p(b)
[{'test': 1},
{'test': 1},
{'test': 1},
{'test': 1},
{'test': 1},
{'test': 1},
{'test': 1},
{'test': 1},
{'test': 1},
{'test': 1}]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment