Dangerous behavior of list(generator)
Terry Reedy
tjreedy at udel.edu
Mon Dec 14 01:46:52 EST 2009
On 12/13/2009 10:29 PM, exarkun at twistedmatrix.com wrote:
> Doesn't matter. Sometimes it makes sense to call it directly.
It only makes sense to call next (or .__next__) when you are prepared to
explicitly catch StopIteration within a try..except construct.
You did not catch it, so it stopped execution.
Let me repeat: StopIteration is intended only for stopping iteration.
Outside that use, it is a normal exception with no special meaning.
Terry Jan Reedy
More information about the Python-list
mailing list