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

Decorators Info

A decorator in Python is a function that takes another function as an argument and extends the behavior of the original function without permanently modifying it. Decorators allow common patterns to be abstracted for reuse. The decorator syntax uses the @ symbol to add extended functionality to a function at compile time.

Uploaded by

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

Decorators Info

A decorator in Python is a function that takes another function as an argument and extends the behavior of the original function without permanently modifying it. Decorators allow common patterns to be abstracted for reuse. The decorator syntax uses the @ symbol to add extended functionality to a function at compile time.

Uploaded by

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

What is a Decorator?

------------------------
1. A Decorator in Practicality is Also a Function, Which Has The Ability To Add
Some Functionality and Returns The Added Functionality to The Calling Environment
2. By Using Decorators The Programmer Can Add Extended Functionality To The
Existing Functional Code
3. The Concept of Decorators is Also Called as "Meta Programming", in This Case A
Part of The Program Tries To Modify Another Part of The Program At Compile Time

Pre-Requisites To Implement Decorators


----------------------------------------------
1. The Concept of Functions in Python Should Be Clear
1. Definition of The Function
2. Call of The Function
3. Formal Parameters of The Function
4. Actual Parameters of The Function
5. The Return Statement of The Function
2. Should Have Clarity on The Concept of Every Function is an Object
3. Every Function Name is Just Like a Concept of an Identifier, Where This
Identifier is Bounded To The Object
4. As The Function is Treated as an Object, We Should Believe That it Has its
Attributes and Behavior
5. The Same Function Can Be Bounded By Different Names, Where Every Name is Acting
as a Reference To The Same Functions Call
6. A Decorator is a Function, Which Adds Some Functionality to The Existing Code
and Returns

Syntax
---------
@decoratorName
def functionName() :
Definition of The Current Function

You might also like