"pass by reference?"
tripps81 at yahoo.com
Tue Feb 26 20:43:23 CET 2002
At 24/02/2002 06:16, Magnus Lyckå wrote:
>>Suppose I want to make a function that modifies its argument:
>> a = -1
>> print a # = 1
>>What is the Pythonic way of doing this? Wrap it in a list?
>You could make 'a' point to a mutable variable, such as
> return map(abs,l)
>a = [-1]
>print a # 1
Ah, yes. Thanks for the correction.
>a = abs(a) is the Pythonic way to do it as others have said.
Got it. Guess I was still thinking in terms of PHP's
func(&$foo). Also, thanks for the juicy and lengthy explanation!
More information about the Python-list