Saturday 11:45–12:30 in Dining

Iterables and Iterators: Going Loopy With Python

Steve Holden

Audience level:
Novice

Description

This talk describes how the interpreter iterates over containers when any construct involving the for keyword is used. It explains both the "old" and the "new" iteration protocols, demonstrates the difference between iterables and iterators, suggests implementation techniques to allow you to define your own iterables and iterators and points out some advantages of generators.

Abstract

The talk's outline is given below. It will take approximately 25 minutes to deliver the material, the remainder being reserved for Q&A.

  1. Iteration History (4 minutes)

  2. Enter the Iterable (10 minutes) Recognizing Iterators Iterating over Iterators Why we Need Iterables

  3. Writing Your Own Iterators and Iterables (10 minutes) The Basic Iterator Pattern The Advantages of Generators The Basic Iterable Pattern Python Native Iterables

  4. Summary (1 minute)