On Fri, 27 Jan 2023 at 06:42, Thomas Ratzke <thomasratzk...@outlook.de> wrote:
>
> Hi all,
>
> i would like to suggest the following Python feature. It naturally
> happens that one want's to repeat the current iteration of a for loop
> for example after an error happened. For this purpose, I usually set a
> flag and put a while loop inside my for loop. A simple "repeat"
> statement just like "continue" or "break" would make the code much more
> readable.
>
>
> This is my solution at the moment with A being checked:
>
> for _ in range(n):
>      flag = True
>      while flag:
>          ...
>          if A:
>              flag = False # go to next iteration
>

Why not use break?

ChrisA
_______________________________________________
Python-Dev mailing list -- python-dev@python.org
To unsubscribe send an email to python-dev-le...@python.org
https://mail.python.org/mailman3/lists/python-dev.python.org/
Message archived at 
https://mail.python.org/archives/list/python-dev@python.org/message/BG3DUXYTZLMZAO3UK545C5YXNY3AA3VA/
Code of Conduct: http://python.org/psf/codeofconduct/

Reply via email to