[egenix-users] Re: No iterator support?

M.-A. Lemburg mal at egenix.com
Mon Oct 29 12:58:14 CET 2007

On 2007-10-29 12:35, Martijn Pieters wrote:
> 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?

No, it should work like that. We'll have a look.

> 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):"

Marc-Andre Lemburg

Professional Python Services directly from the Source  (#1, Oct 29 2007)
>>> Python/Zope Consulting and Support ...        http://www.egenix.com/
>>> mxODBC.Zope.Database.Adapter ...             http://zope.egenix.com/
>>> mxODBC, mxDateTime, mxTextTools ...        http://python.egenix.com/

:::: Try mxODBC.Zope.DA for Windows,Linux,Solaris,MacOSX for free ! ::::

   eGenix.com Software, Skills and Services GmbH  Pastor-Loeh-Str.48
    D-40764 Langenfeld, Germany. CEO Dipl.-Math. Marc-Andre Lemburg
           Registered at Amtsgericht Duesseldorf: HRB 46611

More information about the egenix-users mailing list