Skip to content

Instantly share code, notes, and snippets.

@tututen
Created January 27, 2014 02:51
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 tututen/8642582 to your computer and use it in GitHub Desktop.
Save tututen/8642582 to your computer and use it in GitHub Desktop.
Python の shallow copyとdeep copyについて
In [1]: a=[[0]*5]*4
In [2]: a
Out[2]: [[0, 0, 0, 0, 0], [0, 0, 0, 0, 0], [0, 0, 0, 0, 0], [0, 0, 0, 0, 0]]
In [3]: a[0][0]=1
In [4]: a
Out[4]: [[1, 0, 0, 0, 0], [1, 0, 0, 0, 0], [1, 0, 0, 0, 0], [1, 0, 0, 0, 0]]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment