decorator and wrap

contro opinion contropinion at gmail.com
Mon Jan 9 23:34:51 EST 2012


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??
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-list/attachments/20120110/3412bb95/attachment.html>


More information about the Python-list mailing list