How about something like this<br>
<br>
def foo(bar):<br>
print bar<br>
<br>
d = {"foo":foo}<br>
s = "foo"<br>
params = "bar"<br>
try: d[s](params)<br>
except: KeyError<br>
<br>
Then you can just put the allowed functions into the dictionary.<br><br><div><span class="gmail_quote">On 29/09/05, <b class="gmail_sendername">DS</b> <<a href="mailto:ds-python-tutor@sidorof.com">ds-python-tutor@sidorof.com
</a>> wrote:</span><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">Is it possible to call a function or class by reference, aside from<br>
using an eval approach?<br><br>What I would like to do is have a loop that processes functions by:<br><br> 1. gettting the input that consists of a function and its parameters,<br> 2. determining if the function is on an approved function list,
<br> 3. executing the function<br> 4. rinse, repeat.<br><br>I don't actually mind eval, but I would want to make sure I inspect<br>everything pretty thorougly before executing.<br><br>Thanks for any help you can give me.
<br><br>ds<br>_______________________________________________<br>Tutor maillist - <a href="mailto:Tutor@python.org">Tutor@python.org</a><br><a href="http://mail.python.org/mailman/listinfo/tutor">http://mail.python.org/mailman/listinfo/tutor
</a><br></blockquote></div><br>