← Fullstack with Vue.jsQuestion 12 of 62
How do you write a decorator with arguments (like @timing_logger(threshold=0.1))?
📘 Explanation
A decorator with arguments needs an extra outer layer: the outer function takes the decorator arguments, returns the actual decorator that takes the function, which returns the wrapper that wraps the call. The other options mix up the argument order, pass the function where arguments should go, or add incorrect requirements like forcing **kwargs and functools.partial.
Related questions
← PreviousNo login needed