Confused yet again: Very Newbie Question

Terry Reedy tjreedy at udel.edu
Mon Jul 7 16:45:58 EDT 2008



Jeff wrote:
> When you call c3.createJoe(c1.fred), you are passing a copy of the
> value stored in c1.fred to your function.  Python passes function
> parameters by value.

These statements are both wrong.  Function argument objects or objects 
derived therefrom are bound to function parameter names.  One could say 
that Python calls by cross-namespace assignment.  No copying is done, 
anymore than with assignment statements.

It returns objects the same way if there is a target to receive them.

 >  The function will not destructively modify its arguments;

If the argument is mutable and the function calls a mutation method of 
the object, it is mutated.

tjr




More information about the Python-list mailing list