Tag view

#iterators

Cross-subject tag search for related interview cards.

Clear

Results update as you type. Press / to jump straight into search.

Tagged with iterators

2 cards

Python Hard Theory

Iterable vs iterator, custom iterators, generators, and `send`/`throw`/`close`

An iterable can produce an iterator, an iterator yields values one at a time, generators are a compact way to build iterators, and advanced generator methods can push values or exceptions back in.

  • Iterables and iterators are not the same
  • Generators implement the iterator protocol for you
  • `send`, `throw`, and `close` control generator execution

Iterable vs iterator, custom iterators, generators, and `send`/`throw`/`close`