Aspect-oriented Programming - Diving deep into Decorators
Mike Müller
The tutorial will be hands on. I will start with a blank Notebook for each topic and develop the content step-by-step. The participants are encouraged to type along. My typing speed is usually appropriate and allows participants to follow. The students will receive a comprehensive PDF with all course content as well Python source code files for all use cases and large code blocks I use. I will load these files in my Notebook. The students can do the same or open the files in their preferred editor or IDE.
I also explicitly ask for feedback if I am too fast or things are unclear. I encourage questions at any time. In fact, questions and my answers are often an important part of my teaching, making the learning experience much more lively and typically more useful.
So the participants will be active throughout the whole tutorial. There will be two exercises that each participant has to do on its own (or in breakout rooms if the tutorials should be remote) during the tutorial. We will look at the solutions during the tutorial. I also supply a solutions PDF after the tutorial.
Outline
Session 1
- Examples of using decorators (15 min)
- from the standard library
- from third-party packages
- Closures for decorators (10 min)
- Write a simple decorator (15 min)
- Best Practice (10 min)
- Use case: Caching (10 min)
- Use case: Logging (10 min)
- Exercise (20 min)
Break
Session 2
- Parameterizing decorators (10 min)
- Chaining decorators (5 min)
- Callable instances instead of functions (10 min)
- Use case: Argument Checking (10 min)
- Use case: Registration (10 min)
- Class decorators (15 min)
- Exercise (20 min)
- Wrap-up and questions (10 min)
Mike Müller
Affiliation: Python Academy
I've been a Python user since 1999 and teach Python for a living. I am also active in the community organizing Python conferences such as PyCon DE, EuroSciPy, and BarCamps. I am a PSF Fellow and chair of the Python Software Verband.
visit the speaker at: Homepage