Passing by value instead of reference

Fredrik Lundh effbot at telia.com
Wed May 10 14:57:34 EDT 2000


Jeff Massung <jmassung at magpiesystems.com> wrote:
> >Then what would you expect your "test" function to do?
>
> 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.

>>> z = 5
>>> def test(x):
>>>    x=1
>>> test(z)
>>> print z
5

hmm.  what kind of strange python interpreter are you using?

</F>




More information about the Python-list mailing list