instancemethod

Marc 'BlackJack' Rintsch bj_666 at gmx.net
Mon Jan 22 03:23:02 EST 2007


In <mailman.2973.1169431114.32031.python-list at python.org>, Gert Cuykens
wrote:

>> > >    gert.excecute('select * from person')
>> > >    for x in range(0,gert.rowcount):
>> > >        print gert.fetchone()
>> > >    gert.close()
>> >
>
> […] 
>
> python always seems to amaze me how other languages make a mess of
> things that suppose to be simple

It gets even simpler: cursor objects are iterable after the `execute()`
call. So you don't need the number of rows::

    gert.excecute('select * from person')
    for row in gert:
        print row
    gert.close()

Ciao,
	Marc 'BlackJack' Rintsch



More information about the Python-list mailing list