def decorate(func):
def wrapper(*args, **kwargs):
return func(*args, **kwargs)
return wrapper
@decorate
def test(a=1,b=2):
return a+b
print test.__name__
the result is wrapper. Is there any way make the result is "test"?
Use functools.wraps:
from functools import wraps
def decorate(func):
@wraps(func)
def wrapper(*args, **kwargs):
return func(*args, **kwargs)
return wrapper
@decorate
def test(a=1,b=2):
return a+b
print test.__name__
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With