passing by refference
Joshua Marshall
joshway_without_spam at myway.com
Tue May 13 15:15:57 EDT 2003
Chris Liechti <cliechti at gmx.net> wrote:
> Joshua Marshall <joshway_without_spam at myway.com> wrote in
> news:b9r933$8q0$1 at ginger.mathworks.com:
...
>> This is incorrect terminology. Python has call-by-value semantics,
>> not call-by-reference (it is not possible to pass a reference to a
>> variable into a function).
> uhm...
>>>> def f(x):
> ... print id(x)
> ...
>>>> a=5
>>>> id(a)
> 3328264
>>>> f(a)
> 3328264
>>>>
> as you can clearly see, the reference to the same object is passed into the
> function. but its rebound to a new name in the function. assiging to that
> name just rebinds a new reference to that name, which has no influence on
> the callers namespace.
I said that it's not possible to pass a reference to a /variable/ into
a function. What has been passed to f is not a reference to a
variable, it's a reference to an integer.
More information about the Python-list
mailing list