anything like C++ references?

Tom Plunket tomas at fancy.org
Sat Jul 12 16:53:35 EDT 2003


I want to do something along the lines of the following C++ code:

void change(int& i)
{
   i++;
}


Is there any way to do references like this in Python?  It'd be
like this, though clearly this doesn't change the thing I want it
to change:

def change(val):
   val += 1

v = 0
change(v)

# v == 1 now.

thanks.

I can see that maybe if I passed in a list of one integer I could
change that, but that seems circuitous to me.


-tom!




More information about the Python-list mailing list