There is no do...while because there is no good way to determine which one fits into the statement: indented block pattern used by every other Python composition. Because such sentences to add such syntax never reached agreement.
And there is no need to have such a design, and not when you can just do:
while True: # statement(s) if not condition: break
and have the same effect as the C do { .. } while condition .
See PEP 315 - Improved while loop :
Rejected [...] because there was no syntax that could compete with the following form:
while True: <setup code> if not <condition>: break <loop body>
An alternative syntax suggested by PEP was found for the basic do-while loop, but it received little support, as the condition was at the top:
do ... while <cond>: <loop body>
or, as Guido van Rossum put it :
Please reject PEP. More changes to these lines will not make the language more elegant or easier to learn. They just save some hasty people typing, making others who need to read / maintain their code wonder what that means.
Martijn pieters
source share