8 The Itertools Module

Functional programming emphasizes stateless objects. In Python, this leads us to work with generator expressions, generator functions, and iterables, instead of large, mutable collection objects. In this chapter, we’ll look at elements of the itertools library. This library has numerous functions to help us work with iterable sequences of objects, as well as collection objects.

We introduced iterator functions in Chapter 3, Functions, Iterators, and Generators. In this chapter, we’ll expand on that superficial introduction. We used some related functions in Chapter 5, Higher-Order Functions.

There are a large number of iterator functions in the itertools module. We’ll examine the combinatoric functions in the next chapter. ...

Get Functional Python Programming - Third Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.