Skip to content

Instantly share code, notes, and snippets.

@capttwinky
Created August 23, 2011 23:41
Show Gist options
  • Save capttwinky/1166931 to your computer and use it in GitHub Desktop.
Save capttwinky/1166931 to your computer and use it in GitHub Desktop.
listA = [1,2,3,4] #listA now holds a refrence to a list object
listB = listA #a refrence to the refrence held by listA
listC = list(listA) #a new copy of the object reffered to in the refrence held by listA
listA.append('dog') #update the object reffered to in the refrence held by listA
print(listB) #a refrence to the refrence held by listA -> the object reffered to in the refrence held by listA
print(listC) #the copy we made before updating is, of course, unchanged
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment