PyCon Pittsburgh. April 15-23, 2020.

Tutorial: Introduction to Decorators: Power Up Your Python Code

Presented by:

Geir Arne Hjelle

Description

Python supports functions as first-class objects. This means that functions can be assigned to variables, and passed to and from other functions, just like any other object in Python.

One powerful application of this is the decorator syntax, which makes it easy to apply one function to another at compile time. Decorators offer a simple and readable way of adding capabilities to your code. This tutorial will teach you how decorators work, and how to create your own decorators.

Being comfortable with using and creating decorators, will make you a more efficient Python programmer. You will learn how a single line sometimes can transform your code: add authentication to your website, write a class for you, or even JIT-compile your long-running calculations.

Video

Watch on YouTube