why no break N levels, as in other leading languages?
laotseu
bdesth at removethis.free.fr
Sat May 3 10:35:14 EDT 2003
Evan Simpson wrote:
> Aahz wrote:
>
>> 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
>
>
> This reminds me of a proposal that I actually coded up a Python patch
> for, then lost:
>
> http://groups.google.com/groups?threadm=CXxz3.57%242y4.69103%40news-dal.corridex.com
>
>
> It allowed the above to be written as:
>
> try:
> for i in range(foo):
> for j in range(bar):
> for k in range(spam):
> if my_func():
> break 'Matched'
> continue 'Matched':
> pass
>
> This is more than syntactic sugar, since the association between the
> break statement and the continue clause is completely lexical and static.
>
> I realize that the 'continue' keyword syntax for the break target isn't
> great, but I couldn't think of a better one.
>
Reminds me of an evil (tm) statement known in some others languages.
Should I name it ?-)
Laotseu
PS : who said 'goto' ?
More information about the Python-list
mailing list