Hello,

On Thu, 03 Dec 2020 11:06:41 -0000
"Jonatan " <pybots...@gmail.com> wrote:

> Hi, sometimes I do nested loops and I want to break specific loop,
> outer/inner etc. I need to do an ugly thing with for..else and it's
> annoying.
> 
> It'd be nice if we could do so:
> for i in range(10) as loop_i:
>     for j in range(i, i + 10) as loop_j:
>         if i + j == 9:
>             break loop_i
> or something like this.
> Please comment what do you think about this idea.

Funnily enough, this was mentioned just yesterday on a quite not
directly related thread,
https://github.com/WebAssembly/design/issues/796#issuecomment-737244573 .
As it points out, it's PEP 3136
https://www.python.org/dev/peps/pep-3136/ , proudly bearing the badge
of "Rejected".

And the rejection is likely right than wrong - why patch-up language
with adhoc stuff to break thru loops, if the language already offers
means to break thru *absolutely any levels of anything*, including
nested function calls. It's try/raise, please enjoy its usage for this
purpose too, like other people do already.

-- 
Best regards,
 Paul                          mailto:pmis...@gmail.com
_______________________________________________
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/CBGTGZLG6VCYBB5N6NTGKQHTKDYNCUE5/
Code of Conduct: http://python.org/psf/codeofconduct/

Reply via email to