From something like:
strings = ["f1", "f2"]
I would like to obtain a list of functions to be called later, like:
functions = [f1, f2]
f1 an f2 are the names of 2 methods defined in a python script (not included in a class)
From something like:
strings = ["f1", "f2"]
I would like to obtain a list of functions to be called later, like:
functions = [f1, f2]
f1 an f2 are the names of 2 methods defined in a python script (not included in a class)
On
given:
def f1(): pass
def f2(): pass
you could just look them up in the globals dictionary:
available = globals()
function_names = ["f1", "f2"]
functions = [available[name] for name in function_names]
but note that this is somewhat unsafe, as there's nothing to stop function_names referring to functions you're not expecting.
I think you can have something like:
will return you: [1, 2]