why no break N levels, as in other leading languages?
John Wilson
tug at wilson.co.uk
Fri May 2 02:44:20 EDT 2003
----- Original Message -----
From: "Aahz" <aahz at pythoncraft.com>
Newsgroups: comp.lang.python
To: <python-list at python.org>
Sent: Friday, May 02, 2003 12:58 AM
Subject: Re: why no break N levels, as in other leading languages?
[snip]
> class BreakException(Exception):
> pass
>
> try:
> for i in range(foo):
> for j in range(bar):
> for k in range(spam):
> if my_func():
> raise BreakException
> except BreakException:
> pass
or
for i in range(foo):
for j in range(bar):
for k in range(spam):
if my_func(): break
else:
continue
break
else:
continue
break
Personally I favour putting the loops in a method and using return.
John Wilson
The Wilson Partnership
http://www.wilson.co.uk
More information about the Python-list
mailing list