On Mon, 08 Dec 2008 14:29:01 -0800, Chris Rebert wrote:

> On Mon, Dec 8, 2008 at 2:23 PM, Robert Dailey <[EMAIL PROTECTED]>
> wrote:
>> Hi,
>>
>> I have a string representing the name of a function in Python 3.0. How
>> can I call the function name represented by this string *without*
>> creating a mapping?
> 
> Assuming the function is within scope:
> 
> return_val = vars()[the_string](arguments, go, here)


Or use eval("%s(arguments go here)" % the_string)

(untested in Python 3, but should work)


Are you aware of the great big enormous security hole you're creating if 
the_string is untrusted data?



-- 
Steven
--
http://mail.python.org/mailman/listinfo/python-list

Reply via email to