Posts

Showing posts from 2021

EXERCISE:52 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 to be a modification to the external layer of function, as it does not change its structure. A decorator takes a function and inserts 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 to another part of the program at compile time. Understanding the definition could be difficult, but you can easily grasp the concept through the video section example. In terms of Python, the other function is also called a wrapper. A  wrapper  is a function that provides a wrap-around another function. While using decorator, all the code e...