No, loop-and-a-half! (Re: REPEAT... UNTIL ?)
Michele Simionato
mis6 at pitt.edu
Fri Jul 5 12:52:49 EDT 2002
Greg Ewing <see_reply_address at something.invalid> wrote in message news:<3D24FAC5.3050406 at something.invalid>...
>
> On the other hand, a situation that *is* very common is
> a loop-and-a-half, with the exit condition in the middle.
> So far, I've never seen *any* really good loop-and-a-half
> structure in any language, and I think Python has a chance
> to be truly innovative here.
>
> The syntax I favour at the moment for Python looks like
>
> while:
> line = f.readline()
> gives line <> "":
> do_something()
>
> Some day I'll get around to PEPping this...
Python2.2 has already
for line in f: do_something()
where f is a file object.
--
Michele Simionato - Dept. of Physics and Astronomy
210 Allen Hall Pittsburgh PA 15260 U.S.A.
Phone: 001-412-624-9041 Fax: 001-412-624-9163
Home-page: http://www.phyast.pitt.edu/~micheles/
More information about the Python-list
mailing list