[Tutor] Assigning variables with names set by other variables

Max S. maxskywalker1 at gmail.com
Fri Nov 4 22:21:06 CET 2011


Is it possible to create a variable with a string held by another variable
in Python?  For example,

>>> var_name = input("Variable name: ")
(input: 'var')
>>> var_name = 4
>>> print(var)
(output: 4)

(Yeah, I know that if this gets typed into Python, it won't work.  It just
pseudocode.)

I'm on a Windows Vista with Python 3.2.2.  Thanks.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/tutor/attachments/20111104/65bfbaea/attachment-0001.html>


More information about the Tutor mailing list