By popular demand, a few features commonly found in functional programming
languages like Lisp have been added to Python.
With the lambda keyword, small "anonymous" functions can be created.
Here’s an example:
>>> a=map(lambda x:x*x,range(10))
>>> a
[0, 1, 4, 9, 16, 25, 36, 49, 64, 81]
Lambda forms can be used wherever function objects are required. They are syntactically restricted to a single expression. Semantically, they are just syntactic sugar for a normal function definition. Like nested function definitions, lambda forms can reference variables from the containing scope:
While using lambda there is no scope for using loops and all.
Only a single statement can be included.
With the lambda keyword, small "anonymous" functions can be created.
Here’s an example:
>>> a=map(lambda x:x*x,range(10))
>>> a
[0, 1, 4, 9, 16, 25, 36, 49, 64, 81]
Lambda forms can be used wherever function objects are required. They are syntactically restricted to a single expression. Semantically, they are just syntactic sugar for a normal function definition. Like nested function definitions, lambda forms can reference variables from the containing scope:
While using lambda there is no scope for using loops and all.
Only a single statement can be included.












