PyCon 2019 in Cleveland, Ohio

Friday 10:50 a.m.–11:20 a.m. in Grand Ballroom A

Practical decorators

Reuven M. Lerner

Description

Decorators are one of Python's most powerful features. But even if you understand what they do, it's not always obvious what you can do with them. Sure, from a practical perspective, they let you remove repeated code from your callables. And semantically, they let you think at a higher level of abstraction, applying the same treatment to functions and classes. But what can you actually do with them? For many Python developers I've encountered, ecorators sometimes appear to be a solution looking for a problem. In this talk, I'll show you some practical uses for decorators, and how you can use them to make your code more readable and maintainable, while also providing more semantic power. Moreover, you'll see examples of things would be hard to do without decorators. I hope that after this talk, you'll have a good sense of how to use decorators in your own Python projects.