Get parameter by name

Thomas A. Bryan tbryan at python.net
Sat Nov 6 05:06:16 EST 1999


Oleg Broytmann wrote:

> and I have a list of strings "a1, td, ka". How can I get the value of
> corresponding args? E.g., if I have
> 
>    x = "ka"
> 
> how can I get the value of parameter, the name of which is in x ("ka", in
> this case)?

I'm not sure whether I understand the question.  Is this what you're 
trying to figure out?

>>> ka = 1 
>>> x = 'ka'
>>> eval(x)
1
>>> y = eval(x)
>>> y
1

If not, please repost.

---Tom




More information about the Python-list mailing list