Python 101 : Introduction to decorators


Decorators are a way to add functionalities to a function without altering the original one.

In the below example, we make the original() function print an extra line "added line by the decorator" using a decorator:


Remark:

The above numbers indicate the flow of the program.

The below syntax:


Is equal to:

Comments

Leave as a comment:

Archive