Generator functions

Now we come on to generator functions, one of the most powerful and elegant features of the Python programming language. Python generators provide the means for describing iterable series with code in functions. These sequences are evaluated lazily, meaning they only compute the next value on demand. This important property allows them to model infinite sequences of values with no definite end, such as streams of data from a sensor or active log files. By carefully designing generator functions we can make generic stream processing elements which can be composed into sophisticated pipelines.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset