changing a var by reference of a list

Jorgen Bodde jorgen.maillist at gmail.com
Tue May 8 08:05:26 EDT 2007


Hi,

I am trying to simplify my code, and want to automate the assigning of
variables I get back from a set. I was thinking of putting the
variables I want changed in a list:

L = [self._varA, self._varB ]

self._varA is a variable I want to change when I pass L to a function.
I know doing this;

L[0] = 12

Will replace the entry self._varA with 12, but is there a way to
indirectly change the value of self._varA, through the list, something
like a by-reference in C++ or a pointer-pointer?

With regards,
- Jorgen



More information about the Python-list mailing list