Summary

In this chapter, we studied iterators,  a programming construct very near to a mathematical description of iterative methods. You saw the yield keyword and met finite and infinite iterators.

We showed that an iterator can be exhausted. More special aspects such as iterator comprehension and recursive iterators were introduced and demonstrated with the help of examples.

Get Scientific Computing with Python 3 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.