passing by refference

Aahz aahz at pythoncraft.com
Tue May 13 18:24:29 EDT 2003


In article <mailman.1052859920.24799.python-list at python.org>,
Christopher A. Craig <list-python at ccraig.org> wrote:
>
>If you look at
>http://wombat.doc.ic.ac.uk/foldoc/foldoc.cgi?call-by-value
>
>You will see that it also describes Python's calling strategy.  Python
>always passes the address of an argument variable rather than the
>contents of said variable.  That assignment will overwrite that address
>is not related to the passing strategy.

But reading
http://wombat.doc.ic.ac.uk/foldoc/foldoc.cgi?call-by-reference
illustrates why there is confusion and why call-by-value is a poor
phrase; "value of the argument expression" has no meaning in Python.
Consider:

    def f(x):
        print x

    f(1+2)
    f('1'+'2')
    f([1] + [2])

The fact that you use the phrase "contents of said variable" in contrast
to "address of an argument variable" implies that you don't really
understand how Python works -- to the extent that there is a "variable"
at all, the content *is* the address.  That confusion is precisely why I
and others prefer to use "name" and "binding".
-- 
Aahz (aahz at pythoncraft.com)           <*>         http://www.pythoncraft.com/

"In many ways, it's a dull language, borrowing solid old concepts from
many other languages & styles:  boring syntax, unsurprising semantics,
few automatic coercions, etc etc.  But that's one of the things I like
about it."  --Tim Peters on Python, 16 Sep 93




More information about the Python-list mailing list