How to access object attributes given a string

Santiago Romero sromero at gmail.com
Thu Feb 14 03:33:04 EST 2008


> >> You are using a scripting language.. why not use python directly?
>
> > I just want to execute an small set of commands (PLAYSOUND, PLAYMUSIC,
> > WALKTO, PLAYERSAY, SLEEP and a couple more) ... do you think I can
> > write python code inside my object.exec (list attribute) loaded from a
> > file?
>
> Something like that.
>
> Build a dictionary -that will be used as the script global namespace-
> (...)
>
> Warning: this is unsafe!!!. Malicious users could execute arbitrary code;
> although this may not be an issue if the game runs on the user's own
> system.
>
> The advantage is that you let them use all the power of Python as a
> scripting language.

 That's why I was trying to write my own "small" scripting
language :-).

 It works, but I would like to know how to write it better or safer.
That's why I posted the source code.

 Thanks.




More information about the Python-list mailing list