0% found this document useful (0 votes)
2 views

Decorators in Python

A decorator in Python is a function that adds additional processing capabilities to a normal function and returns a modified value. It takes a normal function as a parameter and defines an inner function that performs operations on the result of the original function before returning it. The syntax involves defining a decorator function that returns the inner function, which must return the modified value.

Uploaded by

ttejender57
Copyright
© © All Rights Reserved
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
2 views

Decorators in Python

A decorator in Python is a function that adds additional processing capabilities to a normal function and returns a modified value. It takes a normal function as a parameter and defines an inner function that performs operations on the result of the original function before returning it. The syntax involves defining a decorator function that returns the inner function, which must return the modified value.

Uploaded by

ttejender57
Copyright
© © All Rights Reserved
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 1

======================================

Decorators in Python
======================================
=>Decorator is one of the Function which will provides Additional Processing
capability to the normal Function value and returns the modified value.
=>A Decorator Function is always takes Normal Function as parameter
--------------
Syntax:-
-------------
def functionname1( functionname ): # Decorator
def innerfunctionname(): # Inner Function name
val=functionname()
--------------------------
#do the operation on ' val '
-------------------------
return resut # Inner Funtion must return modified value
return innerfunctionname # Decorator returns inner function name

=>here functionname1 is called Decorator function


=>here Functionname as a formal parameter . Every decorator function must take
normal function as parameter.
=============================x====================================

You might also like