Python Learning note-day04-Part II (lambda expression)

Source: Internet
Author: User

LAMDBA-expression

Attention:

1. For handling simple logic

The LAMDBA expression is just an expression, not a block of code, only encapsulates the limited logic, for logically complex code

It is also recommended to use the DEF definition function to handle

2. Auto return

The return statement does not need to be used in the LAMDBA expression, and the result is returned automatically.

Cases:

def func (ARG):
Arg+1
The next two pieces of code function the same
Func = lambda Arg:arg +1



For lamdba expressions for multiple parameters, the example is as follows:
Func = Lambda a,b:a+b

Func = Lambda a,b,**kwargs:a+b



This article is from the "'ll Notes" blog, so be sure to keep this source http://timesnotes.blog.51cto.com/1079212/1715264

Python Learning note-day04-Part II (lambda expression)

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.