Issue 846553: Addition to break and continue (original) (raw)

Created on 2003-11-21 12:48 by alexanro, last changed 2022-04-11 14:56 by admin. This issue is now closed.

Messages (4)
msg54055 - (view) Author: Alexander Rødseth (alexanro) Date: 2003-11-21 12:48
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.
msg54056 - (view) Author: Michael Dubner (dubnerm) Date: 2003-11-22 01:43
Logged In: YES user_id=39274 What you will do to exit from outer of two for's from inside inner?
msg54057 - (view) Author: Raymond Hettinger (rhettinger) * (Python committer) Date: 2004-03-13 21:41
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.
msg54058 - (view) Author: Guido van Rossum (gvanrossum) * (Python committer) Date: 2004-03-14 04:24
Logged In: YES user_id=6380 Rejected -- break and continue already have a goto-like flavor (you can easily write really inscrutable code using them) and this would just make it worse.
History
Date User Action Args
2022-04-11 14:56:01 admin set github: 39576
2003-11-21 12:48:12 alexanro create