function-arguments by reference
Paul Rubin
http
Tue Dec 30 08:27:34 EST 2003
"EsC" <christian.eslbauer at liwest.at> writes:
> is it possible to pass function-arguments by reference?
> (for example in PHP you can use the "&" operator ... )
No. If there's a specific situation you want to handle, say what it
is and someone will say how to deal with it in Python. For example if
you want a function that returns multiple values, just return a list:
def get_three_nums ():
return (2, 3, 5)
a, b, c = get_three_nums ()
sets a=2, b=3, and c=5. You don't have to do anything kludgy like
"get_three_nums (&a, &b, &c)" or whatever. If you want to swap two
variables, you can just use a list assignment like in perl:
(x, y) = (y, x)
More information about the Python-list
mailing list