Two standard-library modules complete the functional toolbox. itertools is a collection of fast, lazy tools for looping: joining, slicing, combining and grouping iterators, which you can chain just as you chained generators. operator turns Python’s operators and attribute lookups into functions, so that you need fewer lambdas. Together they let you write many loops as a single readable line.
More lessons in Complete Python Programming