Syntax: pointers versus value

Danny Castonguay castong at
Wed Jul 30 18:46:43 CEST 2003

Simple question but I can't find the answer.  Using an example:

listA = [1 ,2]
listB = listA
#listA now is [1,2,3]

I want to avoid listA's value to change. Clearly, "listB = listA" 
creates the problem.  listB and listA become two pointers to the same 
object.  How then, do I duplicate the two objects; ie make a copy of the 
  object that listA is pointing to and have listB point to that object.

I'm new to python and I love it.

Thank you,

More information about the Python-list mailing list