On Mon, Dec 8, 2008 at 12:26 AM, Bruno Desthuilliers
<[EMAIL PROTECTED]> wrote:
> Colin J. Williams a écrit :
>>
>> [EMAIL PROTECTED] 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
>>>
>>> Many TIA!!
>>> Mark
>>>
>>>
>>
>> Why not run it and see?
>>
>> Your function returns None.
>>
>> The function in effect takes a copy of n.
>
> Nope, it takes the object bound to global name 'n'.

See Also: the earlier heated debate thread over what evaluation
strategy Python uses (Survey says!: call-by-object).

Cheers,
Chris

-- 
Follow the path of the Iguana...
http://rebertia.com

>
> --
> http://mail.python.org/mailman/listinfo/python-list
>
--
http://mail.python.org/mailman/listinfo/python-list

Reply via email to