def <dynamic function name> () syntax ?

Bruce Edge bedge at troikanetworks.com
Thu Apr 5 10:51:15 EDT 2001


Thanks to everyone for the help.
It was very educational to see the different ways of doing this that were
illustrated by everyone's examples.
To answer one question, yes, I was mentally porting a tcl construct to
Python.
I ended up using a simple function name dictionary to map the function
names into a lookup table. This bought me the flexibility I needed.

Once again, thanks to all.

-Bruce.

In article <20010404.095211.716334471.21458 at mead.troikanetworks.com>,
"Bruce Edge" <bedge at troikanetworks.com> wrote:

> Can the follwoing be accomplished in Python?
> 
> I want to create a func named "abc":
> 
>>>> name="abc"
> 
>>>> eval ("name")
> 'abc'
> 
>>>> def eval ("name") ():
>   File "<stdin>", line 1
>     def eval ("name") ():
>                    ^
> SyntaxError: invalid syntax
> 
> 
> Thanks, Bruce.



More information about the Python-list mailing list