reseting an iterator

Alan G Isaac aisaac at american.edu
Wed May 20 15:29:01 EDT 2009


Jan wrote:
> Wouldn't it be easy for Python to implement generating functions so
> that the iterators they return are equipped with a __reset__() method?

Use ``send``:
http://docs.python.org/whatsnew/2.5.html#pep-342-new-generator-features

Remember, there may be no underlying sequence object for
an iterator, and if you want one in that case, you should build it.

Alan Isaac



More information about the Python-list mailing list