instancemethod

Gert Cuykens gert.cuykens at gmail.com
Mon Jan 22 02:12:01 CET 2007


On 1/22/07, Gabriel Genellina <gagsl-py at yahoo.com.ar> wrote:
> "Gert Cuykens" <gert.cuykens at gmail.com> escribió en el mensaje
> news:ef60af090701211416n5b2eb7edt2ee6d4555bd49c1a at mail.gmail.com...
>
> > class Db:
> >
> >    _db=-1
> >    _cursor=-1
> >
> >    @classmethod
> >    def __init__(self,server,user,password,database):
> >        self._db=MySQLdb.connect(server , user , password , database)
> >        self._cursor=self._db.cursor()
> >
> >    @classmethod
> >    def excecute(self,cmd):
> >        self._cursor.execute(cmd)
> >        self._db.commit()
> >
> >
> > 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()
>
> Besides your specific question that was already answered, why are you using
> classmethods at all?
> You are constructing a Db instance and using it as if all were normal
> instance methods... Just remove all those @classmethod declarations and use
> it in a standard way.
>
> --
> Gabriel Genellina
>
>
> --
> http://mail.python.org/mailman/listinfo/python-list
>

i thought @classmethod was the normal method ?


More information about the Python-list mailing list