defprint(" hehe ")print(func) Results:< function Func at 0x1101e4ea0>
The function name is a variable, but it is a special variable that can be used in conjunction with parentheses.
When you print the function name, you will see that a memory address appears.
Function names can be assigned to variables
defprint(" hehe ")print# assign a function as a variable to another variable # function Tuning func ()
Function names can be used as elements of a container class
deffunc1 ():Print("hehe")defFunc2 ():Print("hehe")deffunc3 ():Print("hehe")deffuncc4 ():Print("hehe") LST=[Func1, Func2, Func3,func4] forIinchlst:i ()
Function names can be used as arguments to functions
def func (): print ( eat " " def print ( " I am func2 ) FN () # The FN passed over print ( " I am func2 " # The function func is passed as a parameter to the FUNC2 parameter fn.
Function name can be used as the return value of a function
deffunc_1 ():Print("this is a function 1.")deffunc_2 ():Print("this is a function 2.") Print("this is a function 1.") returnFUNC_2FN= Func_1 ()#function 1. Function 1 Returns the function 2, when FN points to the upper? Function 2FN ()#the function returned by the holder?
Application of Python function name