Why and how "there is only one way to do something"?

Dave Hansen iddw at hotmail.com
Thu Dec 15 11:59:05 EST 2005


On Thu, 15 Dec 2005 14:57:18 +0000 in comp.lang.python, Steve Holden
<steve at holdenweb.com> wrote:

[...]
>Would you say
>
>     do:
>         suite
>     while condition
>
>or what? Basically do ... while and do ... until most naturally put the 

Works for me, though I wouldn't cry if the "while" was changed to
"until" to make the difference between this form and the "while" loop
more obvious.  I don't think there's a good argument for _both_
do-while and do-until, but one or the other would be useful.

The biggest objection I see is the addition of one or two more
keywords, but I don't recall using "do" or "until" as a name in any of
my programs...

>test after the loop body (suite), and it's difficult to think of a 
>consistent and natural syntax for expressing the construct. Not that 
>this stopped lots of people from coming forward with their personal 
>favourites ... some suggestions even offered "n and a half" looping 
>possibilities.

Syntax is the problem?  Specifically the position of the condition
after the loop body?  How do you explain the syntax of the new Python
ternary operation, with the test in the middle, even though it
logically has to be done first?

Right now, I tend to write these loops something like

   while 1:
      do_stuff()
      if exit_condition: break

which offends my sense of aesthetics, but it works.

Regards,
                                        -=Dave

-- 
Change is inevitable, progress is not.



More information about the Python-list mailing list