2 ms·
A decorator is a function that takes a function and returns a modified function - how would you write a decorator without nesting functions? Wrapping the inner
by jonathrg 3y ago
A decorator is a function that takes a function and returns a modified function - how would you write a decorator without nesting functions?
Wrapping the inner function of the decorator with @wraps is quite common - one might consider it a bug in the language that the @wraps feature is not built into the decorator mechanism.
But it is a valid point that decorators should not be presented that early.
- aunderscored 3y agoDecorators don't have to return functions. It's just nice to. The result of the call is bound to the name