The use of the function name
⼀ function name is variable, but it is ⼀ a special variable, and can be performed with parentheses variable ⾏ function.
1, the memory address of the function name
DEF FUNC (): Print ( " Oh " ) Print (FUNC) Results: <function FUNC AT 0x1101e4ea0>
2, function name can be assigned to other variables
DEF FUNC (): Print ( " Oh " ) Print (FUNC) A = FUNC # to function as ⼀ variables for another time assigned to the variable A () # function call Use FUNC ()
3、
Function name can be used as an element of containers
DEF func1 (): Print ( " Oh " ) DEF func2 (): Print ( " Oh " ) DEF func3 (): Print ( " Oh " ) DEF Func4 (): Print ( " Oh " ) LST = [func1, func2 , func3] for i in LST: i ()
4, function name can be used as function parameters
DEF FUNC (): Print ( " eat it " ) DEF func2 (the Fn): Print ( " I am func2 " ) the Fn () # Perform pass over the Fn Print ( " I am func2 " ) func2 (FUNC) # the parameters passed to the function func as func2 parameter fn.
5, the function name can be used as the return value of the function
DEF func_1 (): Print ( " individual cases from a function. 1 " ) DEF func_2 (): Print ( " individual cases from a function 2 " ) Print ( " individual cases from a function. 1 " ) return func_2 Fn = func_1 () # YES function 1. function 1 2 function returns, at this time point is the ⾯ fn 2 function fn () # perform the function returns ⾏ ⾯