Trent Nelson a écrit :
(snip (rather convoluted) decorator example)
> When Python first parses your code, every time it runs into '@A', it
> calls A() in order to get the required decorator function.
It's not happening at parsing time, but when the (decorated) def
statement is executed - that is
> def A():
> print 'warp in A'
> def why(self, *arg, **kw):
> print 'in A'
> print self
> print arg
> print kw
> #self(*arg, **kw)
>
> return why
>
> class T(object):
> @A()
> def test(g, out):
>
On Mon, 22 Oct 2007 14:37:36 +0800, kyo guan wrote:
> def A():
> print 'warp in A'
> def why(self, *arg, **kw):
> print 'in A'
> print self
> print arg
> print kw
> #self(*arg, **kw)
>
> return why
>