while (a=b()) ...

Phil Hunt philh at vision25.demon.co.uk
Thu Apr 29 21:47:12 EDT 1999


In article <19990430000141.A5867 at shalott>
           m.mariani at imola.nettuno.it "Marco Mariani" writes:

> 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?
 
How about:

while 1:
   c = curs.fetchone()
   if not c: break
   print c

 
> while curs.fetchone()
>         print $_

This would mean nothing to me if I hadn't already seen the python
examples -- it is very obscure.

-- 
Phil Hunt....philh at vision25.demon.co.uk





More information about the Python-list mailing list