On Dec 21, 5:57 am, [EMAIL PROTECTED] wrote: > 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
Somewhat colloquial/abbreviated. x is a reference. It does not have elements. You mean "... the first element of the list to which x refers is modified ...". > to the new string and back outside foo(), x[0] will point to the new > string. > > Right? Close enough. -- http://mail.python.org/mailman/listinfo/python-list