Beyond just the standard iteration protocol, Python also provides the itertools module. This module provides a number of iterator building blocks that, used singly or in combination, can create specialized iteration tools for efficient looping.
Using the itertools module
How to do it...
There are three main categories of itertools: infinite iterators, combinatoric iterators, and iterators that terminate on the shortest input sequence.
Infinite iterators
Infinite iterators return values repeatedly until a terminating condition is reached:
-
The count(start=0, step...