#include
function hello(){
struct obj = { char *data = 'hello'}
obj.add = obj_add(obj);
return obj;
}
function obj_add(obj){
function add(value){
obj.data += value;
return obj;
}
}
main(){
test = hello();
test.add('world');
printf(test.data);
}
I
On 2/8/07, Leif K-Brooks <[EMAIL PROTECTED]> wrote:
> def obj():
> result = {'data': 'hello'}
> result['add'] = adder(result)
> return result
>
> def adder(obj):
> def add(value):
> obj['data'] += value
> return add
>
> if __name__ == '__main__':
> test = obj(
def obj():
return {'data':'hello',
'add':add(v)}
def add(v):
data=data+v
if __name__ == '__main__':
test=obj()
test.add('world')
print test.data
I don't know why but i have one of does none class c programing style
moods again. I was wondering if the followin
> 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] ==
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):
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
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:
> > &
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 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()
> >
import MySQLdb
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._curso
ok thx this was just what i was looking for
http://docs.python.org/tut/node7.html#SECTION00760
--
http://mail.python.org/mailman/listinfo/python-list
thx it works now
--
http://mail.python.org/mailman/listinfo/python-list
is there a other way then this to loop trough a list and change the values
i=-1
for v in l:
i=i+1
l[i]=v+x
something like
for v in l:
l[v]=l[v]+x
--
http://mail.python.org/mailman/listinfo/python-list
thx
PS i also cant figure out what is wrong here ?
rex=re.compile('^"(?P[^"]*)"$',re.M)
for v in l:
v=rex.match(v).group('value')
v=v.replace('""','"')
return(l)
v=rex.match(v).group('value')
AttributeError: 'NoneType' object has no attribute '
rex2=re.compile('^"(?P[^]*)"$',re.M)
File "/usr/lib/python2.5/re.py", line 180, in compile
return _compile(pattern, flags)
File "/usr/lib/python2.5/re.py", line 233, in _compile
raise error, v # invalid expression
sre_constants.error: unexpected end of regular expression
?
--
http:/
sorry for repost i just found out the news group comp.lang.python is
the same as python-list@python.org :)
On 5 Jan 2007 20:34:54 -0800, gert <[EMAIL PROTECTED]> wrote:
> Would it not be nice if you could assign decorators to attributes too ?
> for example
>
> class C:
> @staticattribute
> dat
would it not be nice if you could assign decorators to attributes too ?
for example
class C:
@staticattribute
data='hello'
or
class C:
@privateattribute
data='hello'
--
http://mail.python.org/mailman/listinfo/python-list
Ok thx i think i understand it now
>>> class C:
... @staticmethod
... def fn():
... return 'whohoo'
...
>>> C.fn()
'whohoo'
>>>
--
http://mail.python.org/mailman/listinfo/python-list
On 21 Dec 2006 09:44:48 GMT, Duncan Booth <[EMAIL PROTECTED]> wrote:
> "George Sakkis" <[EMAIL PROTECTED]> wrote:
>
> @expr
> def fn(...): ...
>
> is exactly equivalent to:
>
> def fn(...): ...
> fn = (expr)(fn)
>
ok i did my homework reading about decorators
http://www.python.org/doc/2.4.4/whatsn
> > class HelloWorld(object):
> > @cherrypy.exposed
> > def index(self):
> >return "Hello World"
do i have to write @cherrypy.exposed before every def or just once for
all the def's ? and why not write something like @index.exposed ?
in other words i have no idea what @ actually d
Does anybody know how to redirect a post request ?
i have a js file that does a post request to a /php/action.php file
and i would like for the secretary to just do the action method
instead that is defined in her python Http class book, so i can run
both php and python without changing the static
> > The cute secretary's name is "cherrypy.tools.staticdir".
> > Check out her resume at http://www.cherrypy.org/wiki/StaticContent
>
> I think i am in love :)
Cant believe this just works out
import os.path
import cherrypy
pwd = os.path.dirname(os.path.abspath(__file__))
class Http:
_cp_c
> The cute secretary's name is "cherrypy.tools.staticdir".
> Check out her resume at http://www.cherrypy.org/wiki/StaticContent
I think i am in love :)
--
http://mail.python.org/mailman/listinfo/python-list
so far this works
import cherrypy
import os.path
class Http:
def index(self):
f = open(os.path.join(os.path.dirname(__file__), '../htm/index.htm'))
xml = f.read()
f.close()
return xml
index.exposed = True
cherrypy.tree.mount(Http())
if __name__ == '__ma
> FWIW, the first version raises an exception (unless of course the name
> 'index' is already bound in the enclosing scope). And the second won't
> probably work as expected with CherryPy.
class HelloWorld:
def index(self):
return "Hello world!"
index.exposed = True #DOOH!
i skipped rea
Is there a difference between
class HelloWorld:
def index(self):
index.exposed = True
return "Hello world!"
and
class HelloWorld:
def index(self):
self.exposed = True
return "Hello world!"
--
http://mail.python.org/mailman/listinfo/python-list
I would like to lauch a server from outside the side package directory
how do i specify a path with import
#/home/gert/Desktop/www/db/py/start-server.py
import cherrypy
class HelloWorld:
def index(self):
return #external htm file Hello world!
index.exposed = True
if __name__ == '__main__':
29 matches
Mail list logo