+ 2

Why we use lambda instead of creating a function??

i think its better to create function then using lambda..

5th Feb 2017, 5:56 AM
Amit Sony
Amit Sony - avatar
5 Answers
+ 3
Lambdas are generally used for one-time operations. If you plan to use the same generator many times, define it as a function. If not, lambda is your friend :)
5th Feb 2017, 11:38 AM
Kuba SiekierzyƄski
Kuba SiekierzyƄski - avatar
+ 2
1. Inline so you don't have to define separately before using 2. Inline so you don't have to think out a name for it!
5th Feb 2017, 2:20 PM
DotJason
+ 1
i think easier in short term and better as a memory wise
7th Feb 2017, 9:33 AM
Ahmed Hashem Ali
Ahmed Hashem Ali - avatar
0
You can use them as arguments in other functions. Google callback functions, function passing style and functions as first class citizens.
9th Feb 2017, 1:15 AM
1of3
1of3 - avatar
0
I have never seen a lambda function used outside of code golf challenges, so the honest answer is that you don't. I think lambda's themselves are being slowly phased out of Python because they're so heavily neglected. That said, you should try to understand the concepts behind them, even if you'll never use them.
4th Mar 2017, 2:01 AM
Aldrich
Aldrich - avatar