<[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] | Is the following correct? | | x = "some string" | | x is a reference to "some string"
x is a name bound to a string object with value 'some string'. Some people find is useful to call that a 'reference', as you seem to have. Others get confused by that viewpoint. It depend on exactly what one means by 'reference'. | foo(x) | | Reference is passed to function. The first parameter name of foo gets bound to the object referred to by 'x'. Calling that 'passing by reference' sometimes misleads people as to how Python behaves. | In foo: | x += " change" | | Strings are immutable, so x in foo() now points to a different string | than x outside foo(). | Right? A function local name x has no particular relationship to a global name spelled the same, except to confuse things. Best to avoid when possible. The effect of that statement would be the same outside of the function as well, pretty much for the reason given. In general, 'y op= x' is the same as 'y = y op x' except for any side-effects of expression y. Lists are an exception. tjr -- http://mail.python.org/mailman/listinfo/python-list