[Tutor] from string to variable name

frank h. frank.hoffsummer at gmail.com
Thu Oct 5 15:41:39 CEST 2006


hello, i have a string variable that  contains a name that I want to use as
a variablename
putting aside questions of why I would like to do that - i this possible at
all?

so I want to assign a value to a variable whos name is available only as a
string to me.
that variable does not exist yet in the local namespace.

from: t = "myvar"
to: myvar = 3

is this possible? something like setattr?
thanks for any insight you might have
-frank
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.python.org/pipermail/tutor/attachments/20061005/ab3607dd/attachment.htm 


More information about the Tutor mailing list