Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Decorators: simple example

  • A decorator is that @something just before the declaration of the function.
  • Decorators can modify the behavior of functions or can set some meta information about them.
  • In this book first we’ll see a few examples of existing decorators of Python and 3rd party libraries.
  • Then we’ll learn when and how to create our own decorators.
  • Then we’ll take a look at the implementation of some of the well-known decorators.

@some_decorator
def some_function():
    pass