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__['_
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()
>>>
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
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
"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
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
> 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] ==
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
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):
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
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
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):
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
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
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)
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
> > >
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
"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._
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()
> >
>
> 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
20 matches
Mail list logo