Understand and Master the Decorator in Python

Let’s demystify the decorators in Python

Lynn G. Kwong

--

In the most common form, a decorator is a function that takes another function as input, extends its behavior, and returns a new function as output. This is possible because, in Python, functions are first-class objects, which means they can be passed as arguments to functions and also be returned from functions, just as other types of objects such as string, int, or float.

It should be noted that a decorator can also be used to decorate a class. A common use…

--

--

Lynn G. Kwong

I’m a Software Developer (https://medium.com/@lynn-kwong) keen on sharing thoughts, tutorials, and solutions for the best practice of software development.