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
"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 r
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:
>
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 re
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
"George Sakkis" <[EMAIL PROTECTED]> wrote:
> Gert Cuykens wrote:
>> > > class HelloWorld(object):
>> > > @cherrypy.exposed
>> > > def index(self):
>> > >return "Hello World"
>>
>> do i have to
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 ? an
> > 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 oth
e second won't
>>>>probably work as expected with CherryPy.
>>>
>>>
>>>class HelloWorld:
>>>def index(self):
>>> return "Hello world!"
>>>index.exposed = True #DOOH!
>>
>>And the winner is
>>
as expected with CherryPy.
>>
>>
>> class HelloWorld:
>> def index(self):
>> return "Hello world!"
>> index.exposed = True #DOOH!
>
>And the winner is
>
>>
>
>The whole thing, I guess. While Python is quite easy to get s
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.
>
>
>
> class HelloWor
> 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.exp
Gert Cuykens a écrit :
> 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
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.
>
>
> class HelloWorld:
> def index(self):
> index.exposed = True
index is not defined. HelloWorld.index is
Gert Cuykens kirjoitti:
> 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
> retu
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
16 matches
Mail list logo