[Tutor] Dynamically naming functions
Ed Singleton
singletoned at gmail.com
Mon Mar 27 10:42:14 CEST 2006
On 26/03/06, Kent Johnson <kent37 at tds.net> wrote:
> Ed Singleton wrote:
> > 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).
>
> Hi Ed,
>
> I was just wondering how this came out - did you find a way to generate
> these functions dynamically? Or change Faces? Or give up?
I just temporarily delayed the problem. I'm going to have a look at
trying to change the Faces code to use dictionaries as per your
suggestion, but it would a big task for me (my biggest so far
probably).
(I have a new job that lets me do everything in Python, but sometimes
they direct my efforts towards a particular task, which delays my
working on interesting things).
Ed
More information about the Tutor
mailing list