One, the higher order function: Two kinds: One is the return value contains the function body, the other is a function body as a parameter passed to another function
1. The return value contains the function body
Example 1,
1 def Test (): 2 Print (' This is a test ') 3 return Test 4 5 f = test ()6 F ()
1 This is a test 2 This is a test
Example 2
1 definward ():2 Print('From inward')3 defoutward ():4 Print('From outward')5 returnInward6 7f =Outward ()8F ()
1 from Outward 2 from Inward
2. Pass a function body as one parameter to another function
Example 1
1 def Inward (name): 2 print ( " %s is from inward %name) 3 4 def Outward (n): 5 print (" I'm from outside the earth " ) 6 7 Outward (Inward ( ' I ))
1 is from Inward 2 I come from outside the Earth
The path of the Python precipitation--a preliminary understanding of higher order functions