+ 6
What is a decorator ?
9 Answers
+ 4
thanks
+ 3
essentially the simple logic behind decorator is , that you can pass a functions to another function without having to make a variable to hold the location of that function.
+ 3
@charitha This is also called metaprogramming as a part of the program tries to modify another part of the program at compile time.
Functions and methods are called callable as they can be called.
In fact, any object which implements the special method __call__() is termed callable. So, in the most basic sense, a decorator is a callable that returns a callable.
Basically, a decorator takes in a function, adds some functionality and returns it.
This is similar to packing a gift. The decorator acts as a wrapper. The nature of the object that got decorated (actual gift inside) does not alter.
@ symbol along with the name of the decorator function and place it above the definition of the function to be decorated
hope ..it ll help 😇
+ 3
Here is an example of what a decorator may be useful for:
https://code.sololearn.com/cD09ijlIS6Ev/?ref=app
+ 3
T👍👍👍👍👍
👍H👍👍👍👍
👍👍A👍👍👍
👍👍👍N👍👍
👍👍👍👍K👍
👍👍👍👍👍S
+ 2
sorry i am weak in python.
+ 2
Decorator is a function that modifies other functions??
+ 2
decorator provide the nested function
that means we can implement the function from other functions