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 [email protected]: > 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 > > > I would suggest the repeat statement in the following sense > > for _ in range(n): > ... > if not A: > repeat # repeat current iteration > > Notice the "not" in the if clause. I am really looking forwars to hear your > opinions. > > Best regards > Thomas > > _______________________________________________ > Python-Dev mailing list -- [email protected] > To unsubscribe send an email to [email protected] > https://mail.python.org/mailman3/lists/python-dev.python.org/ > Message archived at > https://mail.python.org/archives/list/[email protected]/message/LNER4MH6IT6HBFKFVTUOJ225PTCZSRRC/ > Code of Conduct: http://python.org/psf/codeofconduct/ >
_______________________________________________ Python-Dev mailing list -- [email protected] To unsubscribe send an email to [email protected] https://mail.python.org/mailman3/lists/python-dev.python.org/ Message archived at https://mail.python.org/archives/list/[email protected]/message/S74XCQ6RWBZRO3F5GNAPT4DKKMFVAV2M/ Code of Conduct: http://python.org/psf/codeofconduct/
