August 2018
Intermediate to advanced
366 pages
10h 14m
English
You need to perform the following steps for this recipe:
from functools import wraps
def decorator(f):
@wraps(f)
def _f(*args, **kwargs):
return f(*args, **kwargs)
return _f
@decorator
def sumthree(a, b):
"""Sums a and b"""
return a + back
>>> print(sumthree.__name__) 'sumthree' >>> print(sumthree.__doc__) 'Sums a and b'
If the decorated function had custom attributes, those will be copied to the new function too.