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) https://docs.python.org/3
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