decorator problem1:

Chris Rebert clp2 at rebertia.com
Tue Jan 10 00:17:37 EST 2012


On Mon, Jan 9, 2012 at 7:59 PM, contro opinion <contropinion at gmail.com> wrote:
> test1.py
>
> def deco(func):
>    print 'i am in deco'
>    return func
>
> @deco
>
> def test():
>   print 'i am in test'
>
> when you run it ,you get :
>
>
>
> test2.py
>
> def tsfunc(func):
>     def wrappedFunc():
>         print '[%s] %s() called' % (ctime(), func.__name__)
>         print 'i am in deco'
>         return func()
>     return wrappedFunc
>
> @tsfunc
> def test():
>     print  "i am in test"
>
> when you run test2.py,you can get nothing ,why can't i get  :??
> i am in deco

Same answer applies as the one I just gave in your other thread.

Cheers,
Chris



More information about the Python-list mailing list