Function nesting and function name Parameters

Source: Internet
Author: User

Store the sub-function name as a parameter. When you call this function again, the parameters of the Upper-layer function are still stored.

The operation for storing sub-functions is in upper-layer functions. When passed in, sub-functions can have no parameters, and parameters can be added when called.

The more chaotic, the more direct the demo

1 A = [] 2 def Adda (a1, a2): 3 def addb (A3): 4 print ('--') 5 return A1 + A2 + A3 6. append (addb) 7 print ('+ +') 8 Adda ('000000', '000000') 9 print (a) 10 for AA in: 11 AA ('a3 ') 12 print (AA ('a3 '))

Running result

>>>
++
[<Function addb at 0x0000000002b31898>]
--
--
123456a3
>>>

Function nesting and function name Parameters

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.