itertools

The itertools module contains functions for creating efficient iterators, useful for looping over data in various ways. All the functions in this module return iterators that can be used with the for statement and other functions involving iterators.

chain(iter1,
						iter2, ...,
						iterN)

Given a group of iterators (iter1,..., iterN), this function creates a new iterator that chains all the iterators together. The returned iterator produces items from iter1 until it is exhausted. Then items from iter2 are produced. This continues until all the items in iterN are exhausted.

count([n])

Creates an iterator that produces consecutive integers starting with n. If n is omitted, counting starts at 0. (Note that this iterator does not support long ...

Get Python: Essential Reference, 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.