Skip to content

Instantly share code, notes, and snippets.

@edenau
Last active January 18, 2020 22:00
Show Gist options
  • Save edenau/bc98dceb5fb0e3bb7e7e25c15e11c63a to your computer and use it in GitHub Desktop.
Save edenau/bc98dceb5fb0e3bb7e7e25c15e11c63a to your computer and use it in GitHub Desktop.
import copy
a = [[0,1],[2,3]]
b = copy.copy(a)
print(id(a)==id(b))
# False
b[1] = 100
print(a,b)
# [[0, 1], [2, 3]] [[0, 1], 100]
b[0][0] = -999
print(a,b)
# [[-999, 1], [2, 3]] [[-999, 1], 100]
print(id(a[0]) == id(b[0]))
# True
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment