instancemethod

Gert Cuykens gert.cuykens at gmail.com
Mon Jan 22 00:07:48 CET 2007


On 21 Jan 2007 14:35:19 -0800, Nanjundi <nanjundi at gmail.com> wrote:
> >
> > if __name__ == '__main__':
> >     gert=Db('localhost','root','******','gert')
> >     gert.excecute('select * from person')
> >     for x in range(0,gert.rowcount):
> >         print gert.fetchone()
> >     gert.close()
> >
> > gert at gert:~$ python ./Desktop/svn/db/Py/db.py
> > Traceback (most recent call last):
> >   File "./Desktop/svn/db/Py/db.py", line 35, in <module>
> >     for x in range(0,gert.rowcount):
> > TypeError: range() integer end argument expected, got instancemethod.
> > gert at gert:~$
> >
> > Can anybody explain what i must do in order to get integer instead of
> > a instance ?
>
> Gert,
> >     for x in range(0,gert.rowcount):
> gert.rowcount is the method (and not a data attribute).
> gert.rowcount() is the method call, which get the return value from
> method.
>
> So try this.
> for x in range( 0,gert.rowcount() ):
>

Doh! :)

thx



More information about the Python-list mailing list