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).

Level: advancedTopic: Python advanced

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

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.

Before you go

Take the cheat sheet with you

One free PDF: the key AI-engineering terms, formulas and Python idioms. No spam; unsubscribe any time.