import functools
def log1(f):
def new_test():
print 'call %s()...' % (f.name)
return f()
return new_test
def log2(str):
def log1(f):
def new_test(*argc,*argv):
print '[%s]call %s' %(str,f.name)
return f(argc,**argv)
return new_test
return log1
def log3(str):
def log1(f):
@functools.wraps(f)
def new_test(*argc,*argv):
print '[%s]third time call %s' %(str,f.name)
return f(argc,**argv)
return new_test
return log1
@log1
def test():
pass
print test()
@log2('DEBUG')
def test():
pass
print test()
print test.name
@log3('DEBUG')
def test():
pass
print test()
print test.name