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.

ds


Adam wrote:

> How about something like this
>
> def foo(bar):
>     print bar
>
> d = {"foo":foo}
> s = "foo"
> params = "bar"
> try: d[s](params)
> except: KeyError
>
> Then you can just put the allowed functions into the dictionary.
>
> On 29/09/05, *DS* <[EMAIL PROTECTED]
> <mailto:[EMAIL PROTECTED]>> wrote:
>
>     Is it possible to call a function or class by reference, aside from
>     using an eval approach?
>
>     What I would like to do is have a loop that processes functions by:
>
>         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.
>
>     I don't actually mind eval, but I would want to make sure I inspect
>     everything pretty thorougly before executing.
>
>     Thanks for any help you can give me.
>
>     ds
>     _______________________________________________
>     Tutor maillist  -  Tutor@python.org <mailto:Tutor@python.org>
>     http://mail.python.org/mailman/listinfo/tutor
>     <http://mail.python.org/mailman/listinfo/tutor>
>
>

_______________________________________________
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor

Reply via email to