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 > > class T(object): > @A() > def test(g, out): > print 'in test', out > > it will out put: > > warp in A > in A > <function test at 0x00BF0C70> > () > {} > > the function why will be called, why? there is no code to call it.
There is: [EMAIL PROTECTED]()``. Parenthesis means *calling* `A`. Then `A` returns `why` and that is then used as decorator function, i.e. called with `T.test` as argument. Ciao, Marc 'BlackJack' Rintsch -- http://mail.python.org/mailman/listinfo/python-list