Re: def index(self):

2006-12-22 Thread Fredrik Lundh
Marc 'BlackJack' Rintsch wrote: This depends on the definition of `expr`. If `expr` includes the possibility of enclosing parenthesis then yes. There are scenarios where you would need them. For example if you use objects that overload operators to build a callable used as decorator:

Re: def index(self):

2006-12-22 Thread Duncan Booth
Gert Cuykens [EMAIL PROTECTED] wrote: 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

Re: def index(self):

2006-12-22 Thread Gert Cuykens
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

Re: def index(self):

2006-12-21 Thread Duncan Booth
George Sakkis [EMAIL PROTECTED] wrote: Gert Cuykens wrote: 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

Re: def index(self):

2006-12-21 Thread Gert Cuykens
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/whatsnew/node6.html

Re: def index(self):

2006-12-21 Thread Marc 'BlackJack' Rintsch
In [EMAIL PROTECTED], Gert Cuykens wrote: 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

Re: def index(self):

2006-12-20 Thread Bruno Desthuilliers
HelloWorld: def index(self): return Hello world! index.exposed = True #DOOH! And the winner is /code The whole thing, I guess. While Python is quite easy to get started with, there are a few gotchas. You're above snippet should be: class HelloWorld(object): def index(self): return

Re: def index(self):

2006-12-20 Thread Gert Cuykens
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 does i

Re: def index(self):

2006-12-20 Thread George Sakkis
Gert Cuykens wrote: 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

Re: def index(self):

2006-12-19 Thread Bruno Desthuilliers
Gert Cuykens a écrit : 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. code class HelloWorld: def index(self): return Hello world! index.exposed

Re: def index(self):

2006-12-19 Thread Tim Roberts
Bruno Desthuilliers [EMAIL PROTECTED] wrote: Gert Cuykens a écrit : 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. code class HelloWorld: def index(self

def index(self):

2006-12-18 Thread Gert Cuykens
Is there a difference between code class HelloWorld: def index(self): index.exposed = True return Hello world! /code and code class HelloWorld: def index(self): self.exposed = True return Hello world! /code -- http://mail.python.org/mailman/listinfo/python-list

Re: def index(self):

2006-12-18 Thread Jussi Salmela
Gert Cuykens kirjoitti: Is there a difference between code class HelloWorld: def index(self): index.exposed = True return Hello world! /code and code class HelloWorld: def index(self): self.exposed = True return Hello world! /code The resident experts seemingly being

Re: def index(self):

2006-12-18 Thread Chris Lambacher
On Mon, Dec 18, 2006 at 08:40:13PM +0100, Gert Cuykens wrote: Is there a difference between Yes. The first one causes an exception and the second one doesn't. code class HelloWorld: def index(self): index.exposed = True index is not defined. HelloWorld.index is and self.index

Re: def index(self):

2006-12-18 Thread Bruno Desthuilliers
Gert Cuykens a écrit : Is there a difference between code class HelloWorld: def index(self): index.exposed = True return Hello world! /code and code class HelloWorld: def index(self): self.exposed = True return Hello world! /code Ask yourself what are the names 'index

Re: def index(self):

2006-12-18 Thread Gert Cuykens
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. code class HelloWorld: def index(self): return Hello world! index.exposed = True #DOOH! /code i