Did you know that "for a, (b, c) in s:" is a valid Python line? From the elegant for statement through list/set/dict comprehensions and generator functions, this talk shows how the Iterator pattern is so deeply embedded in the syntax of Python, and so widely supported by its libraries, that some of its most powerful applications can be overlooked by programmers coming from other languages.
UPDATE: Preview slides for this talk can be seen at Speakerdeck Please check them out. Suggestions for improvement are welcome. Some minor fixes are already planned.
UPDATE #2: This talk was selected for a keynote slot at the RuPy Strongly Dynamic Conference in Brazil, December 2012
UPDATE #3: This talk was voted by the community for a slot at PythonBrasil (our PyCon), November 2012
The core of the talk is refactoring a simple iterable class from the classic Iterator design pattern (as implemented in the GoF book) to compatible but less verbose implementations using generators. This provides a meaningful context to understand the value of generators. Along the way the behavior of the iter function, the Sequence protocol and the Iterable interface are presented.
Iteration provides a theme to explore core ideas in the design of Python: the data model, special methods, classic protocols, the new Collections ABC, and why it makes sense that len, reversed and iter are not methods, but built-in functions. Each of these ideas is briefly discussed in the talk, to provide insight and encourage deeper exploration of the language by the attendees.
Topics will be presented roughly in the order shown below. Section times are given for 30'-45' versions.