variable assignment in "while" loop

sismex01 at sismex01 at
Tue Jul 29 17:44:55 CEST 2003

> From: Andy Todd [mailto:andy47 at] 
> Sent: Martes, 29 de Julio de 2003 10:23 a.m.
> Spot on, with one (minor) correction. With a for loop you have to 
> iterate over the results of a call to a method on the cursor, e.g.;
> for info in mydbcursor.fetchall():
>      print "Information:", info
> You could replace fetchall() with fetchmany() or, if you are feeling 
> contrary, fetchone() ;-)
> Regards,
> Andy

Are you sure about this?  Because, if you have to iterate
through .fetchall()  (for example), then the cursor isn't
actually an iterable object, the result of fetchall() is
(it's a list, which is iterable), same goes for fetchmany();
BUT, if you iterate over the results of fetchone() then
you're gonna do a columnwise iteration over a single row.


So... anyone... do cursors have an __iter__() method?
I don't have a DB module at hand to check it out...


Advertencia:La informacion contenida en este mensaje es confidencial y
restringida, por lo tanto esta destinada unicamente para el uso de la
persona arriba indicada, se le notifica que esta prohibida la difusion de
este mensaje. Si ha recibido este mensaje por error, o si hay problemas en
la transmision, favor de comunicarse con el remitente. Gracias.

More information about the Python-list mailing list