On 25/06/2017 12:58, Markus Meskanen wrote:
I'm a huge fan of the do...while loop in other languages, and it would
often be useful in Python too, when doing stuff like:
while True:
password = input()
if password == ...:
break
[...]I suggest [...]
do:
password = input('Password: ')
until password == secret_password
# This line only gets printed if until failed
print('Invalid password, try again!')
I don't see any significant advantage in providing an extra Way To Do
It. Granted, the "while True" idiom is an idiosyncrasy, but it is
frequently used and IMHO intuitive and easy to get used to. Your
suggestion doesn't even save a line of code, given that you can write:
while True:
password = input('Password:')
if password == secret_password: break
print('Invalid password, try again!')
Regards
Rob Cliffe
_______________________________________________
Python-ideas mailing list
Python-ideas@python.org
https://mail.python.org/mailman/listinfo/python-ideas
Code of Conduct: http://python.org/psf/codeofconduct/