while (a=b()) ...

Nathan Clegg nathan at islanddata.com
Thu Apr 29 19:48:39 EDT 1999


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.

The ideal, of course, would be:

while (c = curs.fetchone()): ...

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



On 30-Apr-99 Marco Mariani wrote:
> Hi all language lawyers!
> 
> Which one is more ugly?
> 
> 
> 
> =====
> 
> c = curs.fetchone()
> while c:
>         print c
>         c = curs.fetchone()
> 
> =====
> 
> while 1:
>       c = curs.fetchone()
>       if c:
>               print c
>       else:
>               break
> 
> =====
> 
> Is there an elegant way?
> 
> 
> while curs.fetchone()
>       print $_
> 
> 
>:-)))
> 
> 
> 
> -- 
> "If you're going to kill someone there isn't much reason to get all
> worked
>  up about it and angry.  Any discussions beforehand are a waste of time.
>  We need to smile at Novell while we pull the trigger."
> 
>  - Jim Allchin, Microsoft corp. -
> 
> -- 
> http://www.python.org/mailman/listinfo/python-list



----------------------------------
Nathan Clegg
 nathan at islanddata.com






More information about the Python-list mailing list