On 28 Feb, 02:24, Steven D'Aprano <[EMAIL PROTECTED] cybersource.com.au> wrote: > Python doesn't do call by reference. Nor does it do call by value. Please > pay no attention to anyone who says it does.
Exactly. Python pass variables the same way as Lisp, which is neither "call-by-value" (cf. C) nor "call-by-reference" (cf. Fortran). The Python equivalent of "pass by reference" is a function that returns its arguments to the caller: def foobar(arg1, arg2, arg3): # Mutate an object shared with the caller. # I.e. calling convention cannot be not "pass-by-value" arg1.whatever = 1 # Rebind variables in the local namespace. # I.e. calling convention cannot be "pass-by-reference" arg1, arg2, arg3 = 1, 2, 3 # Return rebound variables to achieve the effect of # "pass-by-reference": return (arg1, arg2, arg3) # Call the function foobar, and rebind its arguments to its # return values: arg1, arg2, arg3 = foobar(arg1, arg2, arg3) -- http://mail.python.org/mailman/listinfo/python-list