PEP-315 ("do" loop)

Wayne Folta wfolta at netmail.to
Mon Feb 16 21:21:57 EST 2004


Two observations about PEP-315:

1. It's clever, addresses a definite "wart",  and is syntactically 
similar to try/except. But it's syntax seems like an acquired taste to 
me.

2. It is a very general construct, which might be what is called for. 
But I wonder if most of the time it would be used to accomplish 
something like:

while 1:
     line = sys.stdin.readline()
     if line == "\n":
         break

In a neater way? How about, instead, creating an "until" loop:

until line == "\n":
     line = sys.stdin.readline()

Would be defined to work exactly like a while loop except the test is 
not evaluated the first time through the loop. Wouldn't this be akin to 
checking at the end of the loop, while maintaining a more while-ish 
syntax?

Is this at all useful or is something of the order of PEP-315 the way 
to go?
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: text/enriched
Size: 1258 bytes
Desc: not available
URL: <http://mail.python.org/pipermail/python-list/attachments/20040216/1c5da741/attachment.bin>


More information about the Python-list mailing list