Skip to content

Reference: Iterators and generators

Quick-lookup pages. Short, dense, designed to skim. If you're here to learn the topic for the first time, start with Learn instead.

Pages in this section

  • itertools cheatsheet — the whole itertools module on one page: chain, groupby, islice, accumulate, takewhile, dropwhile, tee, and the combinatoric helpers.
  • Iterator protocol reference__iter__, __next__, StopIteration, and the distinction between an iterable and an iterator.
  • Generator syntax referenceyield, yield from, .send(), .close(), and the generator-expression forms.