In python, functions can be stored in other variables and then called as functions themselves.
Example
def myfunction():
print('hello')
myfunction() #prints hello
alias_myfunction = myfunction # store function object in other variable
alias_myfunction() #prints hello as well
# use id to test if myfunction and alias_myfunction point to same object.
print(id(myfunction) == id(alias_myfunction))
Output
hello
hello
True
Both myfunction
and alias_myfunction
store the reference to the function object
This can be confirmed using id
In this particular case
# values -> [x for x in range(-2, 3)]
# test -> poly
def print_function(values, test):
for x in values:
print('f(', x,')=', test(x), sep='')
# When test(x) is called, it is essentially calling poly(x)
def poly(x):
return 2 * x**2 - 4 * x + 2
print_function([x for x in range(-2, 3)], poly)