PEP-0315--Enhanced While Loop: An idea for an alternative syntax

Andrew Koenig ark at acm.org
Wed Feb 18 20:47:39 CET 2004


"Paul Rubin" <http://phr.cx@NOSPAM.invalid> wrote in message
news:7xsmh8qq08.fsf at ruckus.brouhaha.com...
> "Andrew Koenig" <ark at acm.org> writes:
> > Any loop that is currently written in the form
> >
> >     while True:
> >         <statements>
> >         if condition:
> >             break
> >         more statements
>
> If the loop is complicated enough, it's probably easier to just write
> it the way you've written it there.  If it's uncomplicated, there's
> probably a way to do it with iterators, assignment expressions, or
> whatever.  Got a real world example that really benefits from the new
> construction?

I think that reserving "break" for abnormal situations makes programs easier
to understand.  Therefore, I would like a way of saying that I expect the
normal exit (or exits) from the loop to be in the middle.  Whether you
consider this desire to be part of the real world is up to you.





More information about the Python-list mailing list