Python high-order functions

Source: Internet
Author: User

In Python, the function name is also a variable that can be assigned

The function name can also be used as a function parameter, and it can also be used as a function return value

1 def f (n): 2     return n  3  4def  foo (a,b,func):  5  6 7     Ret=func (a) +func (b)  8     return  ret  9  Print(foo (1,2,f))

Operation Result: 5

1 def Foo3 (): 2 3     def inner (): 4         return 8 5  6     return  inner  7  8 ret= Foo3 () 9 Ten # print (ret)  One Print (Ret ())

Result is 8

Python high-order functions

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.