[Fwd: while row = c.fetchone(): # syntax error???]

Pablo Prieto pablo.prieto at dulcesol.es
Fri Aug 11 12:55:20 EDT 2000


Just van Rossum escribió:
> 
> I wrote:
> > And now for the "official" Python idiom, which avoids duplication of the
> > t = c.fetchone() line:
> >
> > while 1:
> >     t = c.fetchone()
> >     if not t:
> >         break
> >     --- # Very intelligent code goes here :)
> 
> And Pablo asked:
> > If that a joke, isn't it?
> 
> 'fraid not...

Sorry. I didn`t notice the first sentence -> t = c.fetchone() line:
(Picture what I've managed to imagine!).
Anyrod, and finishing 'cos I'd be posting in [Tutor] rather than here, I
prefer:
the sillier:
t = c.fetchone()
while t:
  --- # Some-kind-of code
  t = c.fetchone()

rather than other complex-solutions brought here. Don't forget it was a
beginner question. If I'd were looking for troubles I learned Perl. 

Python is fine (looks fine) 'cos sounds neat to me. Otherwise 'while 1:'
is clever but my solution:
    a) Get 1 row
    b) Is empty?: No? Use it and get another; Yes? We are done

is soooo academic!. But I like it. (And these sentences of
while(forever) scares me ;))

Be happy all of you there!

Pablo, from Spain.




More information about the Python-list mailing list