Dear Haael

With python you can write
    for i, j in something ():
        # loop body

This would cover both your examples.

For the first, use itertools.product. For the second, write a custom
iterator.

--
Jonathan


On Sat, 11 May 2019, 18:22 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/

Reply via email to