How to do this? - newbie
Adrian Eyre
a.eyre at optichrome.com
Fri Feb 11 06:49:33 EST 2000
>> But it seems you really want to be able to retrieve the numeric
>> value using the symbol 'a' as a key, and that's what dictionaries
>> are for.
> In fact that is exactly what I ended up doing (using a dictionary) and I
may
> just keep it that way. I was just wondering how to do it the way I asked.
Python 1.5.2+ (#0, Oct 13 1999, 15:40:49) [MSC 32 bit (Intel)] on win32
Copyright 1991-1995 Stichting Mathematisch Centrum, Amsterdam
>>> a=('x', 1)
>>> exec(a[0] + '=' + str(a[1]))
>>> x
1
Don't use it though. Using eval() or exec() is dangerous.
-----------------------------------------------------------------
Adrian Eyre <a.eyre at optichrome.com> - http://www.optichrome.com
More information about the Python-list
mailing list