A callback function, also known as a "call-after" function, is a function passed into another function(main funtion) as an argument, and is invoked after the main function if that main function completes
回调函数,又名回头再调用的函数
This execution may be immediate as in a synchronous(同步) callback, or it might happen at a later time as in an asynchronous(异步) callback
# synchronous callback
def get_square(val):
"The callback funtion"
return val ** 2
def caller(func, val):
"The main funtion"
return func(val)
caller(get_square, 5)
>>> 25
ps:回调函数的难点就是命名╮(╯▽╰)╭~