Is there a way to "reference" a module from a string? For example, the following is quite repetitive:
module = "module1"
if module == "module1":
module1.function1()
elif module == "module2":
module2.function1()
elif module == "module3":
module3.function1()
# Other code...
if module == "module1":
module1.function2()
elif module == "module2":
module2.function2()
elif module == "module3":
module3.function2()
So I was wondering if there was a better way to do it, for example exec(module).function1() (which, doesn't work and probably is unsafe too...)
Alternatively, is there a better way of coding this type of thing? Each file is for different sites but have the same functions.
module = module1(ormodule2ormodule 3) and runmodule.function1(), etc.