iterator pattern itertools ' sure you are convinced of the usefulness of iterators by now soi will add quick mention of the itertools package included in the standard library it contains number of functions that allow you to combine and manipulate iterators in some interesting ways these building blocks have been taken from the world of functional programming and languages like haskell and reimagined in pythonic way for an extensive list of thesedo yourself favor and read the documentation for the itertools library to introduce you to the libraryi just want to mention three functions the first is chain()which allows you to chain multiple iterators one after the other import itertools print(list(itertools chain([ ]range( , )"the quick and the slow"))this iterates over every value in each of the three iterables and converts them all to single list that is printedas follows[ ' '' '' ''' '' '' '' '' ''' '' '' ''' '' '' ''' '' '' '' 'nextwe have the infinite iterator cycle()which allows you to create an iterator that will keep cycling over the elements passed to it indefinitely import itertools cycler itertools cycle([ ]print(cycler __next__()print(cycler __next__()print(cycler __next__()print(cycler __next__()print(cycler __next__()print(cycler __next__()print(cycler __next__()print(cycler __next__()