+ 2
Is "lamda" a function or what?
4 Antworten
+ 9
Technically its a group of functions that are created when the program is being run. They are called lambda functions.
So to answer your question, lambda is a contruct to create funtions..
+ 4
In some sense, but you should not think about it that way. It is an expression, which allows you to create a function
myfunc = lambda parameters: expressions
instead of using the whole
def myfunc(parameters):
expression
way of defining it. You don't even have to name it (like when you pass it as an argument to map() ). If you really want, you can view it as a "function", which yields function objects, though.
Hope that helps, if you have questions, fire away.
+ 2
Kinda .. more like a construct that allows you to create an ad-hoc anonymous function .. you could think of lambdas as the ternary operator is vs. a normal "if/else" conditional structure, it saves time, is one-line-elegant statement, you create it where you use it.
Maybe i've stretched it a little but this is how i see it, same as i see list comprehensions as compared to "for each" constructs
0
lambda should actually be called "make_function" in the words of a Python core developer. But it is called lambda for historic reasons, and once it's here, it sticks pretty much forever...