On 2008-01-17, Steven D'Aprano <[EMAIL PROTECTED]> wrote: > On Thu, 17 Jan 2008 11:40:59 +0800, J. Peng wrote: > >> May I ask, python's pass-by-reference is passing the object's reference >> to functions, but perl, or C's pass-by-reference is passing the variable >> itself's reference to functions. So althought they're all called >> pass-by-reference,but will get different results.Is it? > > Python is not call by reference. > > Any book or person that says it is, is wrong to do so. > > Python's function call semantics are not the same as C, or Perl, or > Pascal. They are, however, similar to those of Lisp, Scheme, Emerald and > especially CLU. It is neither pass by reference, nor pass by value.
I don't think it is the function call semantics that are so different as it is the assignment itself that is different. an assignment in C, doesn't bind a new object to the name, but stores new information in the object. Trying to explain the different behaviour of C and python of examples calling function that assign to a parameter, without explaining how the assignment works will IMO not give people enough to understand what is happening. -- Antoon Pardon -- http://mail.python.org/mailman/listinfo/python-list