How to stop iteration with __iter__() ?

ssecorp circularfunc at gmail.com
Tue Aug 19 13:39:44 CEST 2008


I want a parse a file of the format:
movieId
customerid, grade, date
customerid, grade, date
customerid, grade, date
etc.

so I could do with open file as reviews and then for line in reviews.

but first I want to take out the movie id so I use an iterator.

then i want to iterate through all the rows, but how can I do:
while movie_iter != None:

because that doesn't work, itraises an exception, StopItreation, which
according to the documentation it should. But catching an exception
can't be the standard way to stop iterating right?



More information about the Python-list mailing list