AI engineering glossary · Python advanced
What is decorator with arguments?
Decorator with arguments: A decorator factory: a function that takes settings and returns the actual decorator. It needs three nested layers, the factory, the decorator and the wrapper, and is written as @name(args).
Decorator with arguments: an example
@retry(times=3) uses a factory retry that builds a decorator making a flaky API call retry up to three times.
Related terms
- Decorator
- Closure
- Higher-order function
- functools.wraps
More Python advanced terms
Where you learn it
Decorator with arguments is part of the AI Engineering Program, which teaches it with notes, a hands-on lab and an exam. The first lesson is free.