Python 2.7.10运行带参数装饰器报错: 'NoneType' object is not callable
import time
def performance(unit):
def fn(f):
def printtime(*args,**kw):
t1=time.time()
r=f(*args,**kw)
t2=time.time()
t = (t2 - t1)*1000 if unit =='ms' else (t2 - t1)
print 'call %s() in %f %s'%(f.__name__,t,unit)
return r
return printtime
return fn
@performance('ms')
def factorial(n):
return reduce(lambda x,y: x*y, range(1, n+1))
print factorial(10)