Today, while reading a book, I saw a statement like this:
if or isinstance (value,float): split_function=Lambda
The lambda function is very confused, so I looked at the Python document, which is explained in the following document:
-
Lambda
An
-
anonymous-inline function consisting of a single
expression which was evaluated when the function is Called. The syntax to create a lambda function is lambda [arguments]: expression
- The lambda function is also called an anonymous function, that is, the function does not have a specific name, and the method created with Def is a name.
- Lambda allows the user to quickly define a
single-line function , and of course the user can complete the function according to a typical function definition. The purpose of lambda is to simplify the process of user-defined usage of functions.
- For example:
log2=Lambda x:log (x)/log (2)
is to define a logarithmic function with a base of 2. This example is a parameter, and there is a case where there is no parameter:
>>>bar=Lambda :'This isa bar'>>>print is a bar
Lambda functions in Python