Hi On Thu, Dec 3, 2020 at 2:02 PM Chris Angelico <ros...@gmail.com> wrote:
> well... uhhh.... Technically you can do that already.... > > for a in aaa: > for b in bbb: > if condition(a, b): > break > else: > continue # We didn't break from b, so continue a > break # We did break b, so break a This is ingenious. Thank you. Here the "else ... continue" block is for normal exit, and the suite of statements containing the break statement is for unusual exit. > But I don't think anyone's actually doing that :) > We're sort of using the 'break ... continue' as a goto, that goes to the suite after the else block. And though not in name a goto, it has the same problems as a honest goto statement. I consider your example, Chris, to be an argument in favour of allowing 'for ... if break ... else ...'. -- Jonathan
_______________________________________________ Python-ideas mailing list -- python-ideas@python.org To unsubscribe send an email to python-ideas-le...@python.org https://mail.python.org/mailman3/lists/python-ideas.python.org/ Message archived at https://mail.python.org/archives/list/python-ideas@python.org/message/HOD2VPENRPUK3UXHBO3TNS6DXV4WJ2QT/ Code of Conduct: http://python.org/psf/codeofconduct/