[Python-Dev] Re: Dangerous exceptions (was Re: Another test_compiler mystery) (original) (raw)

Guido van Rossum gvanrossum at gmail.com
Tue Sep 7 03:46:59 CEST 2004


It's not really the same subject, but the exception that gives me the most grief is StopIteration. I have to keep remembering to never call .next() without catching it; if I forget, I get bugs where some loop several levels back in the call tree mysteriously exits.

Are you sure? This sounds like superstition to me, since that's not how loops work. Raising StopIteration in the middle of a loop does not break out of the loop -- only raising StopIteration from a next() breaks a loop.

Or are you talking about nested next() calls? That's the only case where the behavior you are citing occurs.

-- --Guido van Rossum (home page: http://www.python.org/~guido/) Ask me about gmail.



More information about the Python-Dev mailing list