Turning Strings into Functions

Richard Brodie R.Brodie at rl.ac.uk
Fri Sep 26 04:54:52 EDT 2003


"Freddy" <freddycooper01 at yahoo.com> wrote in message
news:46610d4e.0309251516.45a8eb01 at posting.google.com...

> How do you turn a string into a callable function? I'm writing a
> program which takes user input and then looks up the associated
> function to run from a shelved dictionary.

I see you have an answer already, so I'll give you a question.
Is there any particular reason why you are storing the name
of the function in the dictionary rather than the function itself?

i.e. myDict["Case1"] = {"desc":"This is Case1", "func1": Handler1} etc







More information about the Python-list mailing list