Home > Articles > Open Source > Python

Deitel Presents Introduction to Python Iterators

  • Print
  • + Share This
Iterators are new to the Python language—they were added in version 2.2. In this article, Deitel™ motivates the need for iterators and define a class that supports iterators.
Like this article? We recommend

Like this article? We recommend

In this article, we motivate the need for iterators and define a class that supports iterators. Iterators are new to the Python language--they were added in version 2.2. Classes that hold sequences of values are prime candidates for iterators. If a class supports iterators, then a client of the class can use a for loop to progress through the items in the class's sequence. Readers should be familiar with OOP (constructors, the object reference argument, private attributes, class customization) and exception handling. The code examples included in this article show readers examples using the Deitel™ signature LIVE-CODE Approach.

View the entire article in PDF format.

  • + Share This
  • 🔖 Save To Your Account