DECORATORS IN PYTHON
May 19, 2022
Press enter or click to view image in full size![]()
Python has an interesting feature called decorators to add functionality to an existing code.
This is also called metaprogramming because a part of the program tries to modify another part of the program at compile time.
Get Bhavatharani’s stories in your inbox
Join Medium for free to get updates from this writer.
There are three rules of functions:
- Reference of a function to another function
- A function name can be passed as an argument
- A function can return another function
Syntax for Decorator:
@gfg_decorator
def hello_decorator():
print("Gfg")'''Above code is equivalent to -def hello_decorator():
print("Gfg")
hello_decorator = gfg_decorator(hello_decorator)'''





