[Python-Dev] Re: Feature Suggestion: "repeat" statement in loops

2023-01-28 Thread Steven D'Aprano
On Thu, Jan 26, 2023 at 08:34:04PM +0100, Thomas Ratzke 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. Can you give an example of when you

[Python-Dev] Re: Feature Suggestion: "repeat" statement in loops

2023-01-28 Thread Matthias Görgens
I don't think 'repeat' should make it into the language. But: it's an excellent test case to check how flexible the language already is. Joao did a great job demonstrating what's possible! On Thu, 26 Jan 2023, 21:15 Joao S. O. Bueno, wrote: > I don't think this will fly - if not for any other

[Python-Dev] Re: Feature Suggestion: "repeat" statement in loops

2023-01-27 Thread Jen Kris via Python-Dev
Why would "if not A" also be true when you repeat the current iteration?  What keeps this from becoming an endless loop? Jan 26, 2023, 11:45 by thomasratzk...@outlook.de: > Hi all, > > i would like to suggest the following Python feature. It naturally happens > that one want's to repeat the

[Python-Dev] Re: Feature Suggestion: "repeat" statement in loops

2023-01-26 Thread Chris Angelico
On Fri, 27 Jan 2023 at 06:42, Thomas Ratzke 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

[Python-Dev] Re: Feature Suggestion: "repeat" statement in loops

2023-01-26 Thread Joao S. O. Bueno
I don't think this will fly - if not for any other reason, it is a very rare pattern to take place alongside such important flow-control statements as continue and break But for your convenience, here is a small wrapper that, along with the walrus operator, could be used when you need that