开发者

Mako calling function from string?

开发者 https://www.devze.com 2023-01-18 22:14 出处:网络
Is there an easy way to call a function give开发者_JAVA百科n a string name in mako?You should be able to look it up in the dict returned by globals(). Eg.:

Is there an easy way to call a function give开发者_JAVA百科n a string name in mako?


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.

0

精彩评论

暂无评论...
验证码 换一张
取 消