How do I use a variable as a function name so that I can have a list of functions and initialize them in a loop. I'm getting the error I expected which is str object is not callable. But I don't know how to fix it. Thanks.
#Open protocol configuration file
config = configparser.ConfigParser()
config.read("protocol.config")
# Create new threads for each protocol that is configured
protocols = ["ISO", "CMT", "ASCII"]
threads = []
threadID = 0
for protocol in protocols:
if (config.getboolean(protocol, "configured") == True):
threadID = threadID + 1
function_name = config.get(protocol, "protocol_func")
threads.append(function_name(threadID, config.get(protocol, "port")))
# Start new threads
for thread in threads:
thread.start()
print ("Exiting Main Protocol Manager Thread")