PEP-315 ("do" loop)

Stefan Axelsson sax at csmisc72.cs.chalmers.se
Wed Feb 18 09:32:09 EST 2004


In article <403280F4.C16FD379 at alcyone.com>, Erik Max Francis wrote:
> It's also analogous to the way do...while structures are written in
> other languages, as well, so it lends familiarity by import.

Which I think is the problem. Python has generators/iterators, which
work very well with the 'for' loop.

Thus the ugliness of e.g:

>while True:
>    line=infile.readline()
>    if line == '':
>        break

is an excellent opportunity to introduce generators/iterators in
general (and the built in iterator of files in particular):

>for line in infile:
>    # do stuff


Stefan,
-- 
Stefan Axelsson                  (email at http://www.cs.chalmers.se/~sax)



More information about the Python-list mailing list