0
Assigning the function name to a variable..
def multiply(x, y): return x * y a = 4 b = 7 operation = multiply print(operation(a, b)) #Why we do this? #Any real life example would help.. thank you..
5 odpowiedzi
0
One way to use it is doing a shortcut: think a function you would call by a.b.c.d.e.t.g.j() just give the name func to that function, and there is your shortcut.
0
confused
0
yes that has a meaningful in project level we will use decorators.
Decorators are used when we have requirement like we have to execute some thing before we need to execute our function and after execution function we need to execute something
let me make simple for example your execution is like this " something yourfucnction something " then we will pass our name of a function as a parameter so these type of notations need at that time
- 1
Thanks all for the answers.. @Swamy Kanuri your answer is not clear.. I am not able to understand what you want to explain..
I have found a solution.. do check my code for the same and let me know your suggestions regarding the same..
https://code.sololearn.com/chLd1B52dwrP#py
Happy Coding..!!! :)