This post is on Python Decorators. We’ll discuss the application of Decorators with examples and ways to create and play with it.
In Python, Decorators have special meaning they can be called on other methods or functions using @ symbol. With decorators, you can extend or change the functionality of python functions.
Python Decorators can be considered as an effective solution to numerous challenges. Before you proceed we advised you to learn python programming tutorial.
Which we have for you in this link of introduction to Python programming.
Let us start with a simple example by using function has an object. In Python functions, classes are associated as objects
def add(a,b):
c=a+b
return c
some_variable = add
print(some_variable)
print(help(some_variable))
#PYTHON OUTPUT
Help on function add in module __main__:
add(a, b)
~
~
~
~
~
~
Help on function add in module __main__:
add(a, b)
#python #learn python #code learners