Session: Iterators, Generators and Decorators

Tags:
, ,
Location:
A05/A06
Duration:
July 24, 2014 10:00 - 13:00
Language:
English
Target-audience:
Advanced

Iterators, generators and decorators are language features of Python that allow to write elegant solutions for certain types of problems. This tutorial provides a hands-on introduction to the underlying concepts. Numerous examples show what you can do with them in your daily programming work.

You will learn how iterators, generators and decorators work and how to write better and more efficient programs with them. If you are new to these topics or tried but got confused about functions that return functions that return functions, this tutorial will help you to understand the how and the why.

This tutorial is a systematic introduction to the topics iterators, generators and decorators. It covers all relevant information with a focus on practical applications for common tasks.

You will learn how iterators, generators and decorators work and how to write better and more efficient programs with them. If you are new to these topics or tried but got confused about functions that return functions that return functions, this tutorial will help you to understand the how and the why.

It is a part of the advanced training I've been delivering over the last years in open and in-house courses as well as trainings at EuroPython, PyCon PL, PyCon DE and PyCon IE. The material has been continuously refined owing to participant feedback.

Iterators and Generators

  • Iterators (15 min)
  • Generator functions (10 min)
  • Generator expressions (10 min)
  • Coroutines (15 min)
  • Chaining (5 min)
  • Itertools (15 min)
  • Exercises (20 min)

Decorators

  • Using decorators (5 min)
  • Writing simple decorators (15 min)
  • Parameterized decorators (10 min)
  • Chaining decorators (5 min)
  • Class decorators (5 min)
  • Best practice (10 min)
  • Application for:
    • Argument checking (3 min)
    • Caching (3 min)
    • Logging (3 min)
    • Registering (3 min)
    • Verification (3 min)
  • Exercises (25 min)

Slides

Link