Python Tutorial 34 --- "Decorators in Python"
Python Tutorial 34 --- "Decorators in Python" What is Python Decorator? Decorator as can be noticed by the name is like a designer that helps to modify a function. The decorator can be said as a modification to the external layer of function, as it does not make any change in its structure. What a decorator does is, it takes a function and insert some new functionality in it without changing the function itself. A reference to a function is passed to a decorator and the decorator returns a modified function. The modified functions usually contain calls to the original function. This is also known as metaprogramming because a part of the program tries to modify and add functionality into another part of the program at compile time. Understanding the definition could be difficult but we can grasp the concept easily through the example in the video section. In terms of python, the other function is also called a wrapper. A wrapper is a function that prov...