Open this example in the interactive library
Source code
from functools import wraps
def twice(fn):
@wraps(fn)
def wrapper(value):
return fn(value) * 2
return wrapper
@twice
def square(value):
return value * value
print(square(3), square.__name__)Sample output
18 square
