PEP-315 ("do" loop)

Paul Prescod paul at prescod.net
Wed Feb 18 08:50:45 EST 2004


John Roth wrote:

> 1. The proposed syntax breaks Python's indentation scheme in a manner that
> try-except, for-else, while-else, and if-elif-else do not.

How so?

> 2. What I find more serious is that there are a huge number of ways to go in
> "improving" the basic while loop, none of which seem to be a natural
> stopping point. Python's philosophy seems to be to find the "sweet spot"
> where you gain the most leverage with the minimum amount of mechanism.
> Neither PEP-315 nor any of the "improvements" I've seen do that.

Could you enumerate some of these? To me, there is only one big flaw of 
the while loop: y forcing you to do the test at the top it also forces 
you to contort your code by duplicating the setup line. Sometimes 
testing at the bottom or in the middle is just the most natural thing. 
"break" caters to it but has its own issues (hiding hte loop condition, 
double-indenting the exit point, etc.).

I've also heard some complain that "while True" is confusing.

I don't know what other ways of "improving" the loop you're referring to.

  Paul Prescod






More information about the Python-list mailing list