Search⌘ K

Extended Syntax for Decorators

Explore Python's extended decorator syntax introduced in version 3.9, allowing more complex expressions to create more compact and reusable code. Understand when to apply this feature wisely to keep decorators clear and maintainable.

Python 3.9 introduced a novelty for decorators with PEP-614, because a more general grammar is allowed. Before this enhancement, the syntax for invoking decorators (after the @) was restricted to very limited expressions, and not every single Python expression was ...