Dangerous behavior of list(generator)

exarkun at twistedmatrix.com exarkun at twistedmatrix.com
Mon Dec 14 14:05:29 EST 2009


On 06:00 pm, tjreedy at udel.edu wrote:
>On 12/14/2009 10:21 AM, exarkun at twistedmatrix.com wrote:
>>I'm asking about why the behavior of a StopIteration exception being
>>handled from the `expression` of a generator expression to mean "stop
>>the loop" is accepted by "the devs" as acceptable.
>
>Any unhandled exception within a loop stops the loop,
>and the exception is passed to the surrounding code.
>>To continue your
>>comparison to for loops, it's as if a loop like this:
>>
>>for a in b:
>>c
>>
>>actually meant this:
>>
>>for a in b:
>>try:
>>c
>>except StopIteration:
>>break
>
>No it does not.

No what does not?  I said "It is as if".  This is a hypothetical.  I'm 
not claiming this is the actual behavior of anything.
>>Note, I know *why* the implementation leads to this behavior.
>
>You do not seem to know what the behavior is.
>Read what I wrote last night.

Well, I'm a bit tired of this thread.  Please disregard my question 
above.  I'm done here.  Sorry for the confusion.  Have a nice day.

Jean-Paul



More information about the Python-list mailing list