Aytek YĆ¼ksel wrote:

/ ...

> What's the reason that when I assign something to person3, person4
> doesn't change although they are aliases (or aren't they?)

> person1 = "Tim"
> person2 = person1
> person2[0] = "s" # This changes both

In this example, you changed one character of an existing object, a string,
but you did not create a new object. The change you made was reflected in
both references to that object.

> person3 = "Tim"
> person4 = person3
> person4 = "s"

In this example, you caused a variable to refer to an entirely new object,
abandoning the old object reference.

Any time you can manipulate the content of an object without creating a new
object, all references to that object will show the change.

But if you cause one object to be replaced by another, the referring
variable will refer to the new object and abandon the old.

-- 
Paul Lutus
http://www.arachnoid.com