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:
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
16 matches
Mail list logo