Skip to content

Instantly share code, notes, and snippets.

@yadvr
Created July 14, 2015 15:12
Show Gist options
  • Select an option

  • Save yadvr/fe85fb02e1a7fda2fd2d to your computer and use it in GitHub Desktop.

Select an option

Save yadvr/fe85fb02e1a7fda2fd2d to your computer and use it in GitHub Desktop.
deepcopy vs list
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
@yadvr

yadvr commented Jul 14, 2015

Copy link
Copy Markdown
Author

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 :)']

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment