How to use a function name as a parameter in Python? For example:
def do_something_with(func_name, arg):
return func_name(arg)
where 'func_name' might be 'mean', 'std', 'sort', etc.
For example:
import numpy as np
func_list = ['mean', 'std']
for func in func_list:
x = np.random.random(10)
print do_something_with(func, x)
and of course the result should a successful application of 'mean' and 'std' on my array 'x'.