Skip to content

Latest commit

 

History

History
18 lines (10 loc) · 874 Bytes

File metadata and controls

18 lines (10 loc) · 874 Bytes

Generators

Suppose you have to produce a sequence of data, such as words from some text. One idea is to generate them all at once. Another idea is to write a generator, which generates a word each time it is needed. By writing a generator, you can leave it up to the process that uses words to decide how many of them they will want to receive.

Generators are a basic notion of Python, and are instrumental in the implementation of iterators. Here we present them, along with some applications.

Notebook

Video

Possible problem sets

  • Generators and recursion.