+ 6

What is a decorator ?

21st Nov 2017, 4:03 PM
Charitha Sri
Charitha Sri - avatar
9 odpowiedzi
+ 4
thanks
25th Nov 2017, 6:46 PM
Charitha Sri
Charitha Sri - avatar
+ 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.
21st Nov 2017, 5:35 PM
jay
+ 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 😇
21st Nov 2017, 5:40 PM
Prashant Singh
Prashant Singh - avatar
+ 3
Here is an example of what a decorator may be useful for: https://code.sololearn.com/cD09ijlIS6Ev/?ref=app
25th Mar 2018, 4:32 PM
Denys Yeromenko
Denys Yeromenko - avatar
+ 3
T👍👍👍👍👍 👍H👍👍👍👍 👍👍A👍👍👍 👍👍👍N👍👍 👍👍👍👍K👍 👍👍👍👍👍S
12th Feb 2019, 6:29 PM
Charitha Sri
Charitha Sri - avatar
+ 2
sorry i am weak in python.
7th Dec 2017, 3:26 PM
Shalmon Chavan
Shalmon Chavan - avatar
+ 2
Decorator is a function that modifies other functions??
26th Dec 2017, 10:31 AM
Abrar Saqib
Abrar Saqib  - avatar
+ 2
decorator provide the nested function that means we can implement the function from other functions
18th Feb 2018, 3:54 AM
Ritesh Kumbhare
Ritesh Kumbhare - avatar