"always passes by reference"

Greg Weeks weeks at golden.dtc.hp.com
Sun Jul 30 12:24:54 EDT 2000


[I should have mentioned this in my previous response, but I missed it:]

Martijn Faassen (m.faassen at vet.uu.nl) wrote:
: This seems to be where the confusion comes in. When people claim Python
: passes by value, because the *references* are being passed by value, 
: that seems to be just stating that the only thing the computer can pass
: in the end is numbers. If you say that, everything is by value

Not really.  The question is *which* number do you pass to the function:
the number written in the argument variable or the address of the argument
variable (which is then implicitly dereferenced).  Perl passes the latter
(call by reference), Python passes the former (call by value).  So, in Perl
you can have:

    $x = 0;
    f($x);
    print "$x\n";		# PRINTS 42

Greg



More information about the Python-list mailing list