[Python-Dev] PEP 351 - do while

Phillip J. Eby pje at telecommunity.com
Sun Oct 1 19:55:06 CEST 2006

At 12:58 PM 10/1/2006 -0400, Andrew Koenig wrote:
> > (I don't think this has been suggested yet.)
> >
> >      while <enter_condition>, <exit_condition>:
> >         <body>
>This usage makes me uneasy, not the least because I don't understand why the
>comma isn't creating a tuple.  That is, why whould
>         while x, y:
>                 <body>
>be any different from
>         while (x,  y):
>                 <body>
>My other concern is that <exit_condition> is evaluated out of sequence.

This pattern:

      while entry_cond:
      and while not exit_cond:

has been suggested before, and I believe that at least one of the times it 
was suggested, it had some support from Guido.  Essentially, the "and while 
not exit" is equivalent to an "if exit: break" that's more visible due to 
not being indented.

I'm not sure I like it, myself, but out of all the things that get 
suggested for this issue, I think it's the best.  The fact that it's still 
not very good despite being the best, is probably the reason we don't have 
it yet.  :)

More information about the Python-Dev mailing list