【发布时间】:2013-06-08 14:31:51
【问题描述】:
我尝试使用以下代码创建装饰器。
def outer():
def inner():
print 'inner called'
return inner
foo = outer()
foo()
但它给出了错误
TypeError: 'NoneType' object is not callable
请解决我的问题。谢谢..
【问题讨论】:
-
另外,作为装饰者,
outer应该将要装饰的函数作为参数。 -
是的,这不是一个真正的装饰器,它实际上只是一个包装函数
-
对不起,它真的是包装函数。
标签: python python-2.7 python-decorators