If I may propose `break n` as a replacement for the original message's `break break ... break`, where n>0 is the number of contiguous loops to break out of and `break 1` is synonymous with `break`. Seems easier on my eyes/noggin than counting out the individual `break` statements.
Eli On Sat, May 11, 2019, 10:21 AM haael <ha...@interia.pl> wrote: > > Python allows for breaking out from a loop through 'break' and > 'continue' keywords. It would be nice if it was possible to break many > loop levels using one command. > > I propose two constructions for that: > > break > break break > break break break > ... > > continue > break continue > break break continue > ... > > And so on. > > Example: > > for i in range(10): > for j in range(10): > if i == 2 and j == 3: > break break > > for i in range(10): > for j in range(10): > if i == 2 and j == 3: > break continue > if i == 7: > break break > > Breaking out from many loops at once is a common practice, currently > implemented through boolean testing and exceptions. This proposal would > make it cleaner. > > _______________________________________________ > Python-ideas mailing list > Python-ideas@python.org > https://mail.python.org/mailman/listinfo/python-ideas > Code of Conduct: http://python.org/psf/codeofconduct/ >
_______________________________________________ Python-ideas mailing list Python-ideas@python.org https://mail.python.org/mailman/listinfo/python-ideas Code of Conduct: http://python.org/psf/codeofconduct/