the next is my code,it can print 'xxx', but run wrong at last:
def a(object):
print 'xxx'
@a
def b():
return 'bbb'
b()
In your answers, please try to use code examples rather than text, because my English is not very good. Thank you.
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
The decorator form
@ameans:is exactly the same as:
So, write
aas a higher order function, AKA HOF: specifically, a function that takes a function object as an argument, and returns a function object.As you give NO idea in your question about what
ais supposed to DO, you’re really making it impossible to give a code example that makes any sense whatsoever: good English or not, you’re really polluting SO, not contributing to it, by your questions, since you never explain WHAT are you trying to accomplish in your code!!!