Hi,

> I was wondering how I can read
> commands from the XML file and then execute them in the game.
    ...
> I just need some way of
> being able to read from the file what function the program needs to
> call next. Any help is appreciated.

One thing you could do is use the eval or compile methods. These
functions let you run arbitray code passed into them as a string.

So, for instance, you can write:
my_list = eval('[1,2,3,4]')

and my_list will then be assigned the list [1,2,3,4], moreover:

eval("my_list.%s" % "reverse()")

or ... even further .. :-)

command = "reverse"
eval("my_list.%s()" % "reverse")

will reverse my_list

Is that something like what you're looking for?

-steve

-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to