[Python-ideas] A suggestion for a do...while loop

Serhiy Storchaka storchaka at gmail.com
Sun Jun 25 08:10:30 EDT 2017


25.06.17 14:58, Markus Meskanen пише:
> 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

In this particular case you could write:

     for password in iter(input, secret_password):
         ...

In more complex cases you can either write more complex generator or 
just use conditional break. There is nothing wrong with this.



More information about the Python-ideas mailing list