newbie question

Martijn Faassen m.faassen at vet.uu.nl
Sat May 12 20:39:39 EDT 2001


Kalle Svensson <kalle at gnupung.net> wrote:
> Sez Uwe Schmitt:
>> 
>> is it right that there is no "do .... loop until"-construct in
>> python ? if yes, why ? i know you can simulate such a loop
>> with a "while ..."-construct.

> Yes.
> I believe the reason why is that Guido didn't/don't want it.

> There was a thread about this recently that evolved into a quite nasty
> flamewar.  Read it for more...

Okay, not to have any long thread about it here, but to summarize the
issues:

The main question is that we don't know any good pythonic syntax for it,
because of indentation. One of the few warts of indentation based block
structure, perhaps:

do:
   some code here
   and some more
until bar

or should we write:

do:
  some code here
  and some more
  until bar

And we don't really have any syntactic equivalent of any of this in the
current Python syntax.

You can indeed simulate it with 'while'; but perhaps you weren't aware of the
following idiom:

while 1:
   some code here
   if bar:
       break

which is the usual way to deal with the occasional do..until loop in Python.
Most people consider it good enough.

If you want a loooong discussion about this, there are multiple 
very big threads you can look up, for instance at groups.google.com.
These threads contain probably most if not all of the suggestions,
ideas and arguments involving this topic, so please read them all
before you go make one of your own. Don't feel refrained from posting
here on other topics though; if you read all those threads now we may
never see you again. :)

Regards,

Martijn
-- 
History of the 20th Century: WW1, WW2, WW3?
No, WWW -- Could we be going in the right direction?



More information about the Python-list mailing list