【发布时间】:2016-02-22 10:18:08
【问题描述】:
将函数映射到字典时,python 会在调用键之前自动执行函数。这可以防止吗? 示例:
def testfunc():
print 'Executed'
testdict = { '1': testfunc(),}
>>>EXECUTED
如果没有,有没有更好的方法来做到这一点?这会是对装饰师的要求吗?
【问题讨论】:
-
省略函数调用运算符
(),所以'1': testfunc
标签: python function dictionary