[Tutor] Problem with copy

Bill Ferreira billferreira@compuserve.com
Sun, 19 Aug 2001 20:27:14 -0600


"copy" is not making a copy until I change the source value so I guess I'm 
doing something wrong, any suggestions?

 >>> import copy
 >>> x=1
 >>> ix=copy.copy(x)
 >>> ix is x
1

My understanding is that the purpose of copy is to insure that the target 
object (ix in this case) is a different object than the source object (x). 
If I follow up the above code with the following:

 >>> x = 2
 >>> x is ix
0

It certainly seems to me that the "is" operator should have returned 0 in 
both cases. And now:

 >>> x = 1
 >>> x is ix
1

What's going on here?

Thanks,
Bill