[Python-Dev] PEP 340: Breaking out.

Tom Rothamel tom-python-dev at rothamel.us
Tue May 3 17:05:10 CEST 2005

I have a question/suggestion about PEP 340.

As I read the PEP right now, the code:

while True:

    block synchronized(v1):
         if v1.field:


Will never break out of the enclosing while loop. This is because the
break breaks the while loop that the block statement is translated
into, instead of breaking the outer True statement. 

Am I understanding this right, or am I misunderstanding this?

If I am understanding this right, I would suggest allowing some way of
having the iterator call continue or break in the enclosing
context. (Perhaps by enclosing the entire translation of block in a
try-except construct, which catches Stop and Continue exceptions
raised by the generator and re-raises them in the outer context.)

I hope this helps.

Tom Rothamel ----------------------------------- http://www.rothamel.us/~tom/

More information about the Python-Dev mailing list