[Tutor] Dynamically naming functions

Ed Singleton singletoned at gmail.com
Fri Mar 10 10:44:30 CET 2006

How does one go about creating functions, classes, or callable objects
when you don't know their name in advance? (For example you want to
read their names in from a text file or database).

I want to use this in a few different places.  For example Faces, the
Python Project Management Planner Tool Thingy, uses nested functions
to put tasks within a project:

def MyProject():
    start = "2006-03-06"
    resource = Me

    def Task1():
        start = "2006-03-13"

    def Task2():
        effort = "1w"

I'd like to load these from a database (using SQLObject), but I'm not
sure how I can define the name of the function from a filed in a
database (or read in from a text file).

I'd also like to be able to do this in CherryPy/TurboGears so that I
can create a dynamic site structure based on fields in a database.



More information about the Tutor mailing list