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

Peter Hansen peter at engcorp.com
Wed Feb 18 12:50:00 EST 2004


Andrew Clover wrote:
> 
> Andrew Koenig <ark at acm.org> wrote:
> 
> >     while:
> >         x = foo()
> >     and while x != 0:
> >         bar(x)
> 
> This is the best syntax I've seen suggested so far. Tentatively +1
> (shouldn't cause any parser difficulties should it?); the lack of new
> keywords is a plus too.

So 
    while: 

is a synonym for 

    while 1:

in the above, and the line

    and while x != 0:

line is basically a synonym for 

    if x == 0: break

but with the added disadvantages of requiring a syntax change, using
negative logic, and messing with the indentation philosophy in a 
non-intuitive way.

Great.

-Peter



More information about the Python-list mailing list