Code examples from the Primer on Python Decorators tutorial on Real Python.
As noted in the article, most decorators are stored in the file decorators.py
. The exceptions are those decorators that depend on third party packages (Flask and Pint), which are available in decorators_flask.py
and decorators_unit.py
, respectively.
Most of the code examples from the article are available in the examples.py
file.
We’ve put together a short & sweet Python decorators cheat sheet for you that summarizes the techniques explained in this tutorial: