You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

18 line
356B

  1. import functools
  2. def log(text):
  3. def decorator(func):
  4. @functools.wraps(func)
  5. def wrapper(*args, **kw):
  6. print('%s %s():' % (text, func.__name__))
  7. return func(*args, **kw)
  8. return wrapper
  9. return decorator
  10. @log('execute')
  11. def now():
  12. print('2015-3-25')
  13. now = log('execute')(now)
  14. print(now.__name__)