What Are Decorators in Python?
Get a brief introduction to decorators in Python.
We'll cover the following...
Decorators were introduced in Python a long time ago, in PEP-318, as a mechanism to simplify the way functions and methods are defined when they have to be modified after their original definition.
We first have to understand that in Python, functions are regular objects just like pretty much anything else. That means we can assign them to variables, pass them around by parameters, or even apply other functions to them. It is typical to want to write a small function, and then apply some transformations to it, generating a new ...