How to construct and call a function from a string? For example, consider three different functions and a list of strings, I want to be able to use the items in list of strings to construct and call the appropriate function
def do_function1():
return 'done function1'
def do_function2():
return 'done function2'
def do_function3():
return 'done function3'
listOfstr = ['function1','function2','function3']
for item in listOfstr:
result = 'do_'+item()
print(result)
result = 'do_'+item()
TypeError: 'str' object is not callable