Updating variables indirectly

Tommy Grav tgrav at mac.com
Tue Dec 12 09:19:00 EST 2006


I have a little problem that look something like this:

Python 2.4.4 (#1, Oct 18 2006, 10:34:39)
[GCC 4.0.1 (Apple Computer, Inc. build 5341)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
 >>> class test: pass
...
 >>> test.a = 1
 >>> test.b = 2
 >>> for x in [test.a,test.b]:
...   x = x + 1
...
 >>> print test.a
1
 >>> print test.b
2
 >>>

However, what I am after is a way to increment the variables in the  
list,
e.q. I want test.a to be 2 and test.b to be 3.

Is there a way of doing this?

Cheers
    Tommy

tgrav at mac.com
http://homepage.mac.com/tgrav/
------------------------------------------------------------
"Any intelligent fool can make things bigger,
more complex, and more violent. It takes a
touch of genius -- and a lot of courage -- to
move in the opposite direction"
                                                  -- Albert Einstein




-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-list/attachments/20061212/f79b65cb/attachment.html>


More information about the Python-list mailing list