tags:

views:

16

answers:

1

Is there an easy way to call a function given a string name in mako?

+2  A: 

You should be able to look it up in the dict returned by globals(). Eg.:

<$ func_name = 'my_function_name' %>
${globals()[func_name](...)}

Although, this does smell rather nasty to me. If you could expand upon your end game perhaps we can figure out something a bit saner.

Mike Boers
thanks, this is related to http://stackoverflow.com/questions/3842458/python-lookup-function so i'm trying to figure out ways around it
Timmy
I like your interrobang. Also, +1 for a good answer and for getting clarification on why this is needed.
JoshD