Is the following correct?

x = "some string"

x is a reference to "some string"

foo(x)

Reference is passed to function.

In foo:
    x += " change"

Strings are immutable, so x in foo() now points to a different string
than x outside foo().
Right?

Back outside foo.

x = ["some string"]

x is a reference to a list whose first element is a reference to a
string.

foo(x)

Within foo:

x[0] += " other"

Another string is created, the first element of x is modified to point
to the new string and back outside foo(), x[0] will point to the new
string.

Right?
-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to