Generators and Iterators
摘要
In this chapter, you become familiar with generators and iterators. An iterator is a special object that allows you to iterate over a collection. A generator is a particular iterator. So, in any case, you deal with iterating over collections. Let’s start with the more straightforward issue: the generator.