InterviewSolution
| 1. |
Explain Decorator in Python? |
|
Answer» Decorators can be considered as one of the most important and powerful TOOLS that are present in python. We can temporarily modify the behaviour of a function or a class with the help of this tool. Decorator helps to WRAP the function or a class with another function to modify the behaviour of wrapped function or a class without making any permanent changes to that specific function source code. In Python we can easily use or pass functions as ARGUMENTS as they are considered as first-class objects. In Decorator, a function acting as a first-class object can be passed an argument to another function and then it will be called INSIDE the wrapper function. |
|