Created
July 14, 2015 15:12
-
-
Save rohityadavcloud/fe85fb02e1a7fda2fd2d to your computer and use it in GitHub Desktop.
deepcopy vs list
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
import copy | |
a = 1 | |
b = [1,2,3] | |
c = "Some random string :)" | |
z = [a,b,c] | |
x = list(z) | |
x[1][1] = 100 | |
print x | |
print z |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Why list() is wrong, because x == z
In [37]: print x
[1, [1, 100, 3], 'Some random string :)']
In [38]: print z
[1, [1, 100, 3], 'Some random string :)']