Breaking out of nested loops
Skip Montanaro
skip at pobox.com
Sat Jan 12 09:55:40 EST 2002
Tal> One feature I miss in python is the ability to break out of nested
Tal> loops.... The two solutions I've seen -- raising an exception, or
Tal> putting the loop inside a function and using the return statement
Tal> -- are unintuitive...
Tal> Know if anyone has drafted a PEP for a syntactic solution for this
Tal> problem?
Well, if there was a PEP, you'd know where to find it:
http://python.sourceforge.net/peps/
:-) (I don't think there is one.)
This topic comes up periodically without a clear resolution. Not as often
as the indentation thing, but more frequently than implicit "self" arguments
to methods. Try googling for "break nested loops" at
http://www.python.org/search/
You might also consider writing a PEP that at least summarizes what you
find. I'd suggest you consider documenting more than just breaking out of
nested loops:
* alternative looping proposals
* named blocks
* inline functions
* breaking out of nested loops
--
Skip Montanaro (skip at pobox.com - http://www.mojam.com/)
More information about the Python-list
mailing list