Python中的 *args 和 **kw是如何保证装饰器所包装的函数不受参数限制的
import time
def performance(f):
def fn(*args,**kw):
t1 = time.time()
r = f(*args,**kw)
t2 = time.time()
print 'Call %s() in %fs' % (f.__name__,(t2 - t1))
return r
return fn
@performance
def factorial(n):
return reduce(lambda x,y: x*y, range(1, n+1))
print factorial(10)