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..

12th Mar 2017, 11:46 AM
Jignesh
Jignesh - avatar
5 Respostas
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.
12th Mar 2017, 12:48 PM
Amaras A
Amaras A - avatar
0
confused
12th Mar 2017, 1:55 PM
Simon
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
12th Mar 2017, 3:32 PM
Swamy Kanuri
Swamy Kanuri - avatar
- 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..!!! :)
13th Mar 2017, 7:18 AM
Jignesh
Jignesh - avatar