Chris Rebert於 2012年1月10日星期二UTC+8下午1時15分53秒寫道:
> On Mon, Jan 9, 2012 at 8:14 PM, contro opinion wrote:
> > test1.py
> >
> > def deco(func):
> > print 'i am in deco'
> >
> > @deco
> > def test():
> > print 'i am in test'
> >
> >
> > when you run it ,you get :
> > i am in deco
> >
> >
> >
>
On Mon, Jan 9, 2012 at 8:14 PM, contro opinion wrote:
> test1.py
>
> def deco(func):
> print 'i am in deco'
>
> @deco
> def test():
> print 'i am in test'
>
>
> when you run it ,you get :
> i am in deco
>
>
>
> test2.py
>
> def tsfunc(func):
> def wrappedFunc():
> print 'i
test1.py
def deco(func):
print 'i am in deco'
@deco
def test():
print 'i am in test'
when you run it ,you get :
i am in deco
test2.py
def tsfunc(func):
def wrappedFunc():
print 'i am in deco'
return func()
return wrappedFunc
@tsfunc
def test():