var or inout parm?

Aaron Brady castironpi at gmail.com
Mon Dec 8 21:01:42 CET 2008


On Dec 7, 2:54 am, m... at pixar.com wrote:
> How can I make a "var" parm, where the called function can modify
> the value of the parameter in the caller?
>
> def f(x):
>     x = x + 1
>
> n = 1
> f(n)
> # n should now be 2

You can't.  'n' would need a 'set_to' method, which it doesn't have.
Otherwise, that's not what the equal sign does.



More information about the Python-list mailing list