Günter Rote added the comment:
Sorry, that was my misinterpretation of what happened.
I had been stumbling over an old program I had written, but
apparently it works because the while-loop is inside
a generator function, and the StopIteration is simply
passed on.
Here is a small demonstration
R. David Murray added the comment:
>>> while True:
... raise StopIteration
...
Traceback (most recent call last):
File "", line 2, in
StopIteration
--
nosy: +r.david.murray
___
Python tracker
New submission from Günter Rote:
It should be mentioned in the documentation that
A StopIteration exception raised in the body of a while loop will terminate
(and is caught by) the while-loop, thus leading to graceful termination.
A good place would be here:
1)