Feature Requests item #1210975, was opened at 2005-05-29 22:59 Message generated for change (Tracker Item Submitted) made by Item Submitter You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=355470&aid=1210975&group_id=5470
Please note that this message will contain a full copy of the comment thread, including the initial issue submission, for this request, not just the latest update. Category: Python Interpreter Core Group: None Status: Open Resolution: None Priority: 5 Submitted By: Geraint Luff (geraintluff) Assigned to: Nobody/Anonymous (nobody) Summary: "break" and "continue"-ing out of nested 'for' loops Initial Comment: I wasn't entirely sure whether this should go under "Interpreter Core" or "Parser/Compiler", but whatever. At the moment, "break" and "continue" can only break out of the innermost "for" loop. I would appreciate a way of breaking out of multiple 'for' or 'while' loops. This would be extremely useful for instance when you have some 'for' loops cycling through several combinations, and you are using another 'for' loop to check their validity (in my example, checking that my two values are co-prime). In this situation, the only solution I have found is to create a boolean variable that is assigned a value when the check fails, just before 'break'-ing out of a 'for' loop, and immediately after that 'for' loop, having a statement that checks the status of the boolean variable, and then 'continue's or 'breaks' again accordingly. I'm not an experienced programmer, but this strikes me as inefficient :p Sorry if the above explanation is muddled. I can send a short (15 lines) bit of code which might explain it better. BTW, PHP seems to do this with "break 2;" or "continue 2;" which is very useful. --G ---------------------------------------------------------------------- You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=355470&aid=1210975&group_id=5470 _______________________________________________ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com