decorator and wrap
Chris Rebert
clp2 at rebertia.com
Tue Jan 10 00:21:27 EST 2012
Cheers,
Chris
--
http://rebertia.com
On Mon, Jan 9, 2012 at 8:34 PM, contro opinion <contropinion at gmail.com> wrote:
>
> def deco(func):
> def wrap():
> print 'i am in deco'
> return func()
> return wrap
>
> @deco
> def test():
> print "i am in test"
> when you run it ,there is no result ,
>
> def deco(func):
> print 'i am in deco'
> return func()
>
>
> @deco
> def test():
> print "i am in test"
>
>
> when you run it ,you can get :
>>>>
> i am in deco
> i am in test
>
> why??
For the third time, it's because the "I am in deco" `print` is not
within a nested function definition (such as wrap()).
Cheers,
Chris
More information about the Python-list
mailing list