A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from http://mail.python.org/pipermail/python-list/2001-April/082087.html below:

def <dynamic function name> () syntax ?

def <dynamic function name> () syntax ? 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

RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4