while (a=b()) ...

William Tanksley wtanksle at dolphin.openprojects.net
Thu Apr 29 22:59:54 EDT 1999


On Thu, 29 Apr 1999 16:48:39 -0700 (PDT), Nathan Clegg wrote:
>I have some deep-rooted "hates" in programming and don't even know where
>some of them came from.  One of them is "while 1" loops.  They seem
>somehow at the same level as goto statements and should be used, in my
>mind, about as rarely.

I agree.  Especially since while(1) loops require the use of a goto inside
of them.

>The ideal, of course, would be:
>while (c = curs.fetchone()): ...

I have done my own arguing for an assignment expression, but this I can't
countenance.  A while statement containing an explicit assignment isn't
any kind of an ideal; it's a necessary evil.

Thankfully, Python offers some ways around the problem -- making an object
is one of them, and it results in the cleanest while statement (although I
think it's too messy to stay in Python 2).  Hopefully, Python 2 will offer
some other ways -- I rather like Sather-K's notion of streams.

>That is my only complaint about python, that statements cannot be
>expressions.

I've got some other complaints, but in spite of my complaints Python still
is the easiest language I've worked with.  I'm afraid that if they ever
implement any of my suggestions the language will get way worse.  :)

>Nathan Clegg

-- 
-William "Billy" Tanksley
"But you shall not escape my iambics."
           -- Gaius Valerius Catullus




More information about the Python-list mailing list