"pass by reference?"

Enrique ecastro at cicei.ulpgc.es
Sat Feb 23 07:46:48 EST 2002


Hi Tripp

Tripp Scott wrote:
> 
> Suppose I want to make a function that modifies its argument:
> 
>   a = -1
>   make_abs(a)
>   print a # = 1
> 
> What is the Pythonic way of doing this? Wrap it in a list?
> 
>   make_abs([a])
> 
> t

Simply make the function return the modified argument.

a=function(a)

This follows the rule "explicit better than implicit".



More information about the Python-list mailing list