[ubuntu-in] OT: Evaluate an string variable's value to a variable in Python
Mir Nazim
mirnazim at gmail.com
Sun Dec 21 06:51:54 GMT 2008
Hi guys, sorry for the off topic posting, but I know there are a
couple of python guys on the list, so could not resist asking here
Just a quick question.
For example I have
>>> class X
>>> ....pass
Then I do
>>> x = X()
>>> x.name = 'Nazim
Now my question is whether something like below is possible and how
>>> y = 'name'
>>> print x.y # How can x.y can be evaluated to x.name
PS: In PHP this can be done by a $x->$y. I sure there is some way in
Python also, just don't seem to remember/find it right now.
Thanks in advance.
Mir Nazim
Cell: +91 9469071855
Blog: http://saunzal.org
Company:http://www.ikraftsoft.com
More information about the ubuntu-in
mailing list