lambda
is just a fancy way of saying function
. Other than its name, there is nothing obscure, intimidating or cryptic about it. When you read the following line, replace lambda
by function
in your mind:
>>> f = lambda x: x + 1
>>> f(3)
4
It just defines a function of x
. Some other languages, like R
, say it explicitly:
> f = function(x) { x + 1 }
> f(3)
4
You see? It's one of the most natural things to do in programming.