Python Learning-lambda Expression __python

Source: Internet
Author: User
Lambad expression

A lambda expression can create a function that can be called, but it returns a function instead of assigning a function to a variable name, so a lambda function is also called an "anonymous function."

The form of a lambda function is:
Lambda arg1, arg2, ... argn:expression using args
That is: Lambda keywords, parameters, colons, expressions

For example:
”’
f = lambda x, y, z:x+y+z
F (2, 3,4)
”’
Two features:
1. A lambda is an expression, not a statement. That is, a lambda expression can appear where a def is syntactically not allowed, such as in the parameters of a list or function call.
2. The lambda body is a single expression, not code fast. That is, the lambda implementation function is simpler and can only be limited logic (if logic is not even implemented in a lambda).

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.