December 2000
Intermediate to advanced
816 pages
16h 57m
English
Python allows one to create anonymous functions using the lambda keyword. They are “anonymous” because they are not declared in the standard manner, i.e., using the def statement. (Unless assigned to a local variable, such objects do not create a name in any namespace either.) However, as functions, they may also have arguments. An entire lambda “statement” represents an expression, and the body of the lambda expression must also be given on the same line as the declaration. We now present the syntax for anonymous functions using lambda:
lambda [arg1[, arg2, … argN]]: expression
Arguments are optional, and if used, are usually part of the expression as well.
CORE NOTE: lambda expression returns callable ...
Read now
Unlock full access