new to python

Mitja nun at example.com
Sun Oct 10 10:32:44 CEST 2004


Chris Patton wrote:
> I need to make several user-defined objects for a program
> I'm making. I know that one way is to use the exec
> statement (i.e. exec 'raw_input() = "cheese"'), but it
> can get very visually cluttered at times.
> i.e. exec
> raw_input()+num+'={"I":'+b+','+am+':"just","fine":1}'
>
> Does anyone know a different way I can do this? I need to
> do this to define a dictionary, but a general method for
> all objects would be better.

Don't go for global user-defined variables - it's hard to control and a big security risk. A far better thing to do would be
something like

usersVars={}
usersVars[raw_input()]= {4:'sdf', 'foo':'bar'}





More information about the Python-list mailing list