Rheumatic Theory: Functions Are Variables

A function is a variable means that each function name is a variable name, and the process of each function is a variable value. It is equivalent to creating some rooms with house numbers in memory.

def bar():
    print('from bar')
def foo():
    print('from foo')
    bar()

foo()

from foo
from bar

The following will report an error, because before executing the foo function, there is no bar function to get the bar function, and the bar function cannot be found during execution.

def foo():
    print('from foo')
    bar()

foo()

def bar():
    print('from bar')

 

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325297470&siteId=291194637