[ python-Feature Requests-846553 ] Addition to break and continue

SourceForge.net noreply at sourceforge.net
Sat Mar 13 16:41:08 EST 2004


Feature Requests item #846553, was opened at 2003-11-21 07:48
Message generated for change (Comment added) made by rhettinger
You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=355470&aid=846553&group_id=5470

Category: Python Interpreter Core
Group: None
Status: Open
Resolution: None
Priority: 5
Submitted By: Alexander Rødseth (alexanro)
>Assigned to: Guido van Rossum (gvanrossum)
Summary: Addition to break and continue

Initial Comment:
It would be great if one could use "break for", "break
while", "continue for" or "continue while".

A silly example:

for i in range(100):
    counter = 0
    while 1+1 == 2:
        counter += 1
        if counter > 5:
            break for

"break for" should here jump out of the for-loop, as
opposed to just "break" that would jump out of just the
while loop. Using "break for" and friends will make
code a lot more readable and explicit, and avoid using
exception throwing and catching, and other acrobatics.

I believe this suggestion is in sync with the Python
Design guidelines.

----------------------------------------------------------------------

>Comment By: Raymond Hettinger (rhettinger)
Date: 2004-03-13 16:41

Message:
Logged In: YES 
user_id=80475

Guido, I recommend against accepting these forms which are
out of sync with the way the rest of the world uses break,
continue, try, and except.

The proposal is also thin on use cases and does not fit
comfortably with the current implementation.

----------------------------------------------------------------------

Comment By: Michael Dubner (dubnerm)
Date: 2003-11-21 20:43

Message:
Logged In: YES 
user_id=39274

What you will do to exit from outer of two for's from inside
inner?

----------------------------------------------------------------------

You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=355470&aid=846553&group_id=5470



More information about the Python-bugs-list mailing list