Decorators are often thought of as functions that accept functions as arguments and that return other functions...
In this hands-on workshop you will see that this is not always right.
This hands-on workshop is divided into 4 sections of 30 minutes each:
Each section is divided into 15 minutes of live-coded lecture and 15 minutes for exercises where participants work in pairs to solve coding exercises.
The first section briefly recaps the fundamental concepts behind function decorators and the second section introduces the concepts required to write decorators with arguments.
The third section shows how classes can also be decorators, allowing you to create flexible and powerful decorators that leverage the full strength of OOP.
Finally, the fourth section shows how to apply decorators to classes, typically for the purpose of streamlining the definition of some boilerplate code.
Pre-requisites: attendees are expected to have used decorators before and to have written one or two decorators for themselves. Attendees are expected to be comfortable writing classes, methods, and implementing the dunder method __init__.
Set-up: your IDE of choice and Python 3.12+.
Reference materials: the reference materials can be found online at https://decorators.mathspp.com