[Tutor] call a def/class by reference
Danny Yoo
dyoo at hkn.eecs.berkeley.edu
Thu Sep 29 01:52:41 CEST 2005
> Thanks for answering my question. What I'm hoping to avoid is an
> explicit reference to any of the called functions within the program.
> By doing it that way, it would avoid a maintenance problem of having to
> remember to put a reference for every new function in the calling
> program.
In your list of requirements:
> 1. gettting the input that consists of a function and its
> parameters,
> 2. determining if the function is on an approved function list,
> 3. executing the function
> 4. rinse, repeat.
the second one is probably the one that needs clarifying.
How do you know which functions should be callable? Adam's approach to
expressing that knowledge is to use a dictionary:
d = {"foo" : foo}
And there are many other ways of doing this besides a hardcoded
dictionary.
Tell us more about what you mean for a function to be "approved", and we
should be able to suggest practical ways to do what you want.
More information about the Tutor
mailing list