Possible Duplicate:
Understanding Python decorators
Could you please give a short code example that explains decorators?
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.
A decorator takes the function definition and creates a new function that executes this
function and transforms the result.
is equivalent to:
Example:
To understand the decorator, it is important to notice, that decorator created a new function do which is inner that executes func and transforms the result.