why cannot assign to function call

Mark Wooding mdw at distorted.org.uk
Fri Jan 9 22:03:39 CET 2009


Steven D'Aprano <steve at REMOVE-THIS-cybersource.com.au> wrote:

> Python doesn't do the same thing as C. It actually passes the same value 
> to the function, without copying it.
> 
> Why oh why do you keep insisting that Python is no different from C?

I'm beginning to think that you're not bothing to read what I'm writing,
but I'll assume instead that I'm just not writing clearly enough.

In one respect, C and Python are alike.  That respect is that they both
pass arguments to functions `by value'.

In another respect, C and Python are different.  That respect is that
they represent these arguments differently: C stores a binary
representation of the value directly in the object allocated to store it
(6.2.6.1); whereas Python stores a reference to the actual value (3.1,
4.1).

This is what I mean when I say that Python passes arguments by value --
but the `values' that are passed are references.

References to the C standard are to ISO 9899:1999, though I'm fairly
sure that N843 and N1256 will do as well; references to the Python
Language Reference are to the 2.5.2 version dated 2008-02-21.

I'll note here that the PLM uses the term `binding' in the usual sense
understood by the larger programming-language community, and not as a
confusing synonym for assignment.

> Why oh why do you keep insisting that Python is no different from C?

Why oh why do you keep insisting that, because I claim that the two
languages are alike in one respect, that I believe that they must be
alike in a different respect, despite my repeated assertions to the
contrary?

-- [mdw]



More information about the Python-list mailing list