What is an iterator?

An iterator is an object that represents a stream of data. Unlike a sequence, an iterator can (usually) only provide the next item. The for-in statement uses iterators to control the loop, and iterators can also be used in many other contexts.

To add iteration support to your own classes, implement the __iter__ method.

CATEGORY: programming

 

A Django site. this page was rendered by a django application in 0.01s 2008-10-13 00:32:41.113037. hosted by webfaction.