[英]Mako calling function from string?
有没有一种简单的方法可以在mako中调用给定字符串名称的函数?
You should be able to look it up in the dict returned by globals()
. 您应该能够在
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.
如果您可以扩展自己的最终游戏,也许我们可以找出一些更精明的方法。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.