Calling a function or method by name
Jonathan Gardner
jgardn at alumni.washington.edu
Wed Jan 23 17:24:48 EST 2002
On Thursday 24 January 2002 01:14 am, Eric Brunel wrote:
> > I want to use a dict. The keys will be the value of the key being
> > pressed. The values will be the name of the function to call.
>
> Why don't you directly store the methods themselves instead of their names?
> Then, you'll just have to do:
> dict[key]()
>
I remembered the real reason why. I want it to be modifiable with user input.
This means eventually I'll have to convert a string to a function.
Jonathan
More information about the Python-list
mailing list