Jorgen Bodde wrote:

> 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?

No, there isn't.

But you could do

L = ['_varA']

for v in L:
    setattr(self, v, value)

Diez
-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to