Passing by value instead of reference

Jeff Massung jmassung at magpiesystems.com
Wed May 10 14:51:13 EDT 2000


Michael Hudson wrote in message ...
>"Jeff Massung" <jmassung at magpiesystems.com> writes:
>
>> >>> z=5
>> >>> id(z)
>> 6532920
>> >>> def test(x):
>>             print id(x)
>> >>> test(z)
>> 6532920
>>
>> Is there a way to pass the value of z and not the address? Thanks.
>
>Then what would you expect your "test" function to do?
>
>Cheers,
>M.

Just print a different address. If test was:

def text(x):
    x=1

test(z)
print z

I would want this to print the original value of z (5), not 1.

Jeff





More information about the Python-list mailing list