[egenix-users] Re: No iterator support?

Martijn Pieters mj at zopatista.com
Mon Oct 29 12:35:36 CET 2007

On 10/29/07, Martijn Pieters <mj at zopatista.com> wrote:
> Using python 2.4 here. I keep getting "TypeError: len() of unsized
> object" when trying to use a mx.ODBC cursor as an iterator:
>         cursor.execute(query)
>         for row in cursor:
>             # do something with the row
> cursor does have an __iter__ and a next() method, and calling .next()
> does give me a result. Am I doing something wrong here?

The workaround for now is to define an iterator function:

def _iter(cursor):
    while True:
        yield cursor.next()

and use that in "for row in _iter(cursor):"

Martijn Pieters

More information about the egenix-users mailing list