Skip to content

Instantly share code, notes, and snippets.

@amalgjose
Created March 7, 2020 10:38
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save amalgjose/f724d3d6a0070284332902cebeb26562 to your computer and use it in GitHub Desktop.
Save amalgjose/f724d3d6a0070284332902cebeb26562 to your computer and use it in GitHub Desktop.
Implementation of passing list of functions as an argument to another function in python
from math import exp
def exec_func(function_list, p):
"""
This function passes the value p to each element in the function_list.
Each element in function_list is a function
----------
function_list : a list of functions
p : operand
-------
output: The results will be stored in a list and will be the output of this main function
"""
output = []
for function in function_list:
output.append(function(p))
return output
if __name__ == '__main__':
sample_list = [str, abs,exp,int]
print(exec_func(sample_list, 10.0001))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment