Recently I'm learning Python decorator and the use of functools.wraps.
def a(): def b(): def c(): print('hello') return c return b print a.__name__ #output:a I understand why the output is a.But I don't know how __name__ change in the following code.
def log(text): def decorator(func): def wrapper(*args, **kw): print('%s %s():' % (text, func.__name__)) return func(*args, **kw) return wrapper return decorator @log('...') def simple(): print('*' * 20) print simple.__name__ #output:wrapper Why the output is 'wrapper' rather than 'decorator' or 'log'?
functools.wrapsdo?