[Tutor] 2.7.3 generator objects

Steven D'Aprano steve at pearwood.info
Sun Sep 2 12:05:40 CEST 2012


On 02/09/12 17:09, Ray Jones wrote:

> But didn't I read somewhere that you can reset an iterator to go through
> the whole process again?

In general, no.

The usual way to "reset" an iterator is to re-create it.


walker = os.walk("/home/steve/start")
# ... process files in walker
walker = os.walk("/home/steve/start")
# ... and process them again



-- 
Steven


More information about the Tutor mailing list