This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author zach.ware
Recipients Happy Fakeboulder, zach.ware
Date 2018-08-03.19:52:12
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1533325932.45.0.56676864532.issue34332@psf.upfronthosting.co.za>
In-reply-to
Content
Ideas like this are better sent to the python-ideas@python.org mailing list for discussion rather than immediately opening an issue.  Note though that I think this has a low chance of acceptance; there's a very high bar to clear to add syntax, even higher for new keywords, and this doesn't seem to buy much over:

   while True:
       try:
           num = int(input("Enter a number: "))
       except ValueError:
           print("I said a *number*")
       else:
           break
   print("The square of your number is", num**2)

Especially considering that this version allows you to handle the error however you want, and handle different errors differently, rather than just silently restarting the loop no matter the error.

Also, this will be valid in 3.8 and achieve exactly what you're asking for:

   while not (ans := input("Enter a number: ")).isnumeric():
       pass
   print("The square of your number is", int(ans) ** 2)


Do feel free to send your idea to python-ideas anyway, I'm just one opinion :)
History
Date User Action Args
2018-08-03 19:52:12zach.waresetrecipients: + zach.ware, Happy Fakeboulder
2018-08-03 19:52:12zach.waresetmessageid: <1533325932.45.0.56676864532.issue34332@psf.upfronthosting.co.za>
2018-08-03 19:52:12zach.warelinkissue34332 messages
2018-08-03 19:52:12zach.warecreate