September 2026
1051 pages
35h 4m
English
In the previous chapters, we frequently used terms such as iterate or iterable object. Without having defined this exactly, it’s intuitively clear that this means the successive consideration of the individual elements of a corresponding instance. For example, a for loop can be used to iterate over a list:
>>> for x in [1,2,3,4]:... print(x)... 1234
In this chapter, we want to put the notion of iterating on a solid footing by introducing the central concepts of generators and iterators. Then you’ll get to know itertools, a module of the standard library that provides a collection of generators for various interesting use cases.
In this section, we’ll describe the concept of generators, which can ...
Read now
Unlock full access