Hi Jonatan
Please consider
for a in aaa:
for b in bbb:
if condition(a, b):
break
KEYWORD:
break
where KEYWORD is like else, but with the opposite semantics. I think this
does exactly what you asked for, in your example.
In July this year Олег Комлев suggested this addition to the syntax and
semantics, with "if break" as the KEYWORD.
New clause in FOR and WHILE instead of ELSE
https://mail.python.org/archives/list/[email protected]/thread/WNKNETPRGQ3MPQOVG4KG2QV6L7KAPNWM/
I think this is less of a change to the language, and therefore more likely
to be accepted, than what you proposed.
To me
for a in aaa:
for b in bbb:
if condition(a, b):
break
# more code here perhaps
if break:
break
reads quite nicely. If we exited the look with a break, then please do
break again. This also avoids the problem of having to remember and type
label names.
--
Jonathan
_______________________________________________
Python-ideas mailing list -- [email protected]
To unsubscribe send an email to [email protected]
https://mail.python.org/mailman3/lists/python-ideas.python.org/
Message archived at
https://mail.python.org/archives/list/[email protected]/message/BEZ5UD3X3UJCI3WBNOFONTCFF6OL6LU6/
Code of Conduct: http://python.org/psf/codeofconduct/