Pass-by-reference : Could a C#-like approach work in Python?
__peter__ at web.de
Wed Sep 10 16:55:28 CEST 2003
Stephen Horne wrote:
> ... and here is (roughly) what I'd like to be able to do...
>>>> def Inc(ref p) :
> ... p += 1
>>>> x = 1
> Any thoughts?
Obviously, your example could easily be rewritten to
return p + 1
x = inc(x)
and a similar function with two by-ref parameters would still be readable:
x, y = inc2(x, y)
So here's my question. How many functions are there in your *real* code that
could benefit from, say three or more by-ref parameters?
Hint: for me it comes close to 0 :-)
By the way, this is strictly from a user perspective, I trust the Python
developers to overcome the implementation issuses, *if* there is a
significant usability improvement.
More information about the Python-list