Re: instancemethod

2007-01-26 Thread Michele Simionato
On Jan 27, 6:39 am, Steven D'Aprano <[EMAIL PROTECTED]> wrote: > > It seems that the description of __new__ is wrong. Since __new__ takes an > implicit first argument, the class, it is a class method, not a static > method. No: >>> class C(object): ...def __new__(cls): pass >>> C.__dict__['_

Re: instancemethod

2007-01-26 Thread Steven D'Aprano
On Sat, 27 Jan 2007 01:03:50 -0300, Gabriel Genellina wrote: > "Steven D'Aprano" <[EMAIL PROTECTED]> escribió en el > mensaje > news:[EMAIL PROTECTED] > >> On Fri, 26 Jan 2007 17:25:37 +0100, Bruno Desthuilliers wrote: def __del__(self): try: self.close() >>>

Re: instancemethod

2007-01-26 Thread Steven D'Aprano
On Fri, 26 Jan 2007 20:27:29 -0800, Michele Simionato wrote: > On Jan 22, 2:58 am, "Gert Cuykens" <[EMAIL PROTECTED]> wrote: > >> http://www.faqts.com/knowledge_base/view.phtml/aid/16824 > > There is a factual mistake on that reference. The last sentence > >> One final note: the single most com

Re: instancemethod

2007-01-26 Thread Michele Simionato
On Jan 22, 2:58 am, "Gert Cuykens" <[EMAIL PROTECTED]> wrote: > http://www.faqts.com/knowledge_base/view.phtml/aid/16824 There is a factual mistake on that reference. The last sentence > One final note: the single most common use for classmethod is probably > in overriding __new__(). It is alway

Re: instancemethod

2007-01-26 Thread Gabriel Genellina
"Steven D'Aprano" <[EMAIL PROTECTED]> escribió en el mensaje news:[EMAIL PROTECTED] > On Fri, 26 Jan 2007 17:25:37 +0100, Bruno Desthuilliers wrote: >>>def __del__(self): >>>try: >>>self.close() >>>finally: >>>pass >>>except: >>>pas

Re: instancemethod

2007-01-26 Thread Steven D'Aprano
On Fri, 26 Jan 2007 17:25:37 +0100, Bruno Desthuilliers wrote: >>def __del__(self): >>try: >>self.close() >>finally: >>pass >>except: >>pass > > The finally clause is useless here. In principle, closing a file could raise an except

Re: instancemethod

2007-01-26 Thread Gert Cuykens
> class Obj(object): >pass > > toto = tutu = tata = titi = Obj() > > What's an "instance name" ? > > -- > http://mail.python.org/mailman/listinfo/python-list i would say __object__.__name__[3] == toto And if your obj is a argument like something(Obj()) i would say __object__.__name__[0] ==

Re: instancemethod

2007-01-26 Thread Bruno Desthuilliers
Gert Cuykens a écrit : > import MySQLdb > > class Db(object): > >def __enter__(self): >pass > >def __init__(self,server,user,password,database): >self._db=MySQLdb.connect(server , user , password , database) >self._db.autocommit(True) >self.cursor=self._db

Re: instancemethod

2007-01-23 Thread Gert Cuykens
import MySQLdb class Db(object): def __enter__(self): pass def __init__(self,server,user,password,database): self._db=MySQLdb.connect(server , user , password , database) self._db.autocommit(True) self.cursor=self._db.cursor() def execute(self,cmd):

Re: instancemethod

2007-01-23 Thread Bruno Desthuilliers
Gert Cuykens a écrit : > Reading all of the above this is the most simple i can come too. > > import MySQLdb > > class Db: > >def __init__(self,server,user,password,database): >self._db=MySQLdb.connect(server , user , password , database) >self._db.autocommit(True) >s

Re: instancemethod

2007-01-22 Thread Gert Cuykens
Reading all of the above this is the most simple i can come too. import MySQLdb class Db: def __init__(self,server,user,password,database): self._db=MySQLdb.connect(server , user , password , database) self._db.autocommit(True) self.cursor=self._db.cursor() def e

Re: instancemethod

2007-01-22 Thread Bruno Desthuilliers
Gert Cuykens a écrit : > import MySQLdb > > class Db: (snip) >def excecute(self,cmd): >self._cursor.execute(cmd) >self._db.commit() > What about autocommit and automagic delegation ? import MySQLdb class Db(object): def __init__(self,server, user, password, database):

Re: instancemethod

2007-01-22 Thread Marc 'BlackJack' Rintsch
In <[EMAIL PROTECTED]>, 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 suppo

Re: instancemethod

2007-01-21 Thread Gert Cuykens
never mind i think i need some sleep lol i did the exact opposite this time .rowcount() -> .rowcount -- http://mail.python.org/mailman/listinfo/python-list

Re: instancemethod

2007-01-21 Thread Gert Cuykens
import MySQLdb class Db: _db=-1 _cursor=-1 rowcount=-1 def __init__(self,server,user,password,database): self._db=MySQLdb.connect(server , user , password , database) self._cursor=self._db.cursor() def excecute(self,cmd): self._cursor.execute(cmd)

Re: instancemethod

2007-01-21 Thread Gert Cuykens
On 1/22/07, Gert Cuykens <[EMAIL PROTECTED]> wrote: > On 1/22/07, Gabriel Genellina <[EMAIL PROTECTED]> wrote: > > "Gert Cuykens" <[EMAIL PROTECTED]> escribió en el mensaje > > news:[EMAIL PROTECTED] > > > > > class Db: > > > > > >_db=-1 > > >_cursor=-1 > > > > > >@classmethod > > >

Re: instancemethod

2007-01-21 Thread Gert Cuykens
On 1/22/07, Gabriel Genellina <[EMAIL PROTECTED]> wrote: > "Gert Cuykens" <[EMAIL PROTECTED]> escribió en el mensaje > news:[EMAIL PROTECTED] > > > class Db: > > > >_db=-1 > >_cursor=-1 > > > >@classmethod > >def __init__(self,server,user,password,database): > >self._db=MySQ

Re: instancemethod

2007-01-21 Thread Gabriel Genellina
"Gert Cuykens" <[EMAIL PROTECTED]> escribió en el mensaje news:[EMAIL PROTECTED] > 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._

Re: instancemethod

2007-01-21 Thread Gert Cuykens
On 21 Jan 2007 14:35:19 -0800, Nanjundi <[EMAIL PROTECTED]> 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() > >

Re: instancemethod

2007-01-21 Thread Nanjundi
> > 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() > > [EMAIL PROTECTED]:~$ python ./Desktop/svn/db/Py/db.py > Traceback (most recent c