[New-bugs-announce] [issue34332] Suggestion for a new loop type

Happy Fakeboulder report at bugs.python.org
Fri Aug 3 15:28:12 EDT 2018

New submission from Happy Fakeboulder <weird1152 at gmail.com>:

A "while-except" loop, in which it acts like a do-while loop from other languages, except the condition is "did an exception occur during the execution of the iteration". One could specify a type of exception at the top, similar to an except block header. (sorry, I'm an idiot)
Example (the keyword might be different):

# asks for a number until the user gives one properly, then
# calculates the square of it.
whexc ValueError:
    num = int(input("Enter a number: "))
print("The square of your number is " + str(num * num)) # assuming whexc works, this will not cause an error

messages: 323065
nosy: Happy Fakeboulder
priority: normal
severity: normal
status: open
title: Suggestion for a new loop type
type: enhancement
versions: Python 3.4, Python 3.5, Python 3.6, Python 3.7, Python 3.8

Python tracker <report at bugs.python.org>

More information about the New-bugs-announce mailing list