why no "do : until"?

Bjorn Pettersen pbjorn at uswest.net
Wed Jan 3 22:57:37 EST 2001


"A.M. Kuchling" wrote:

> On Wed, 03 Jan 2001 08:21:11 -0700, Bjorn Pettersen
> <pbjorn at uswest.net> wrote:
> >better in the other p-language group. The "while 1" loop seems to be
> >a holy cow in Python.
>
> Hardly; I consider it one of Python's design flaws, and have
> accordingly included it in my list of Python warts
> (http://www.amk.ca/python/writing/warts.html).  But I've managed to
> live with it this far, and don't wish for a do...while that often.

That was hardly a forceful condemnation of "while 1" <wink>. Try
suggesting on the list that you want something like:

   while line := fp.readline()
      ...

or

   repeat:
      ...
   until line != '\n'

and you'll have half a dozen people jumping on your back telling you that
"while 1" is simple, intuitive, and is the only Pythonic way to do things
(you'll have half a dozen other people trying to come up with some clever
wrapper to solve the problem they think you have <wink>).

I have a theory that the same people would tell us how everything you
wanted to do could be done with single inheritance if Python didn't have
MI.

If what you want to do can't be expressed directly in the language, and
the only reason people don't want to change it is because they're used to
the status quo, I feel justified in calling it a holy cow ;-)

you-should-add-print>>None-to-your-list'ly y'rs
-- bjorn





More information about the Python-list mailing list