passing by refference

Joshua Marshall joshway_without_spam at myway.com
Tue May 13 15:07:22 EDT 2003


Terry Reedy <tjreedy at udel.edu> wrote:

...

> To me, call-by-value implies a copy operation, which Python does not
> do.  I think call-by-assignment or call-by-name-binding is more
> accurate.  Given a definition "def f(parname1, parname2): <body>" and
> a call "f(exp1, exp2)" the interpreter evaluates expressions exp1 and
> exp2 as usual and then binds parname1 and parname2 to the resulting
> objects, but in the local namespace of f instead of in the namespace
> where the expressions were evaluated.  A function call is like a
> series of cross-namespace assignment statements.  Once this is
> understood, the effect of modifying mutable arguments is
> understandable.

> Terry J. Reedy

See

  http://wombat.doc.ic.ac.uk/foldoc/foldoc.cgi?call-by-value

What you describe is call-by-value.  There is an implicit copy of the
arguments passed to a function, though not a deep-copy.  The values
that are being copied are often references.




More information about the Python-list mailing list