Deep Dive (Part 2 - Iteration, Generators)

Deep Dive (Part 2 – Iteration, Generators)

Description

Part 2 of this Python 3: Deep Dive series is an in-depth look at:

  • sequences
  • iterables
  • iterators
  • generators
  • comprehensions
  • context managers
  • generator based coroutines

I will show you exactly how iteration works in Python – from the sequence protocol, to the iterable and iterator protocols, and how we can write our own sequence and iterable data types.

We’ll go into some detail to explain sequence slicing and how slicing relates to ranges.

We look at comprehensions in detail as well and I will show you how list comprehensions are actually closures and have their own scope, and the reason why subtle bugs sometimes creep in to list comprehensions that we might not expect.

We’ll take a deep dive into the itertools module and look at all the functions available there and how useful (but overlooked!) they can be.

Leave a Reply