Getting Module dynamically
module, python, python-2.7
Solution
If your "Drivers/" directory in the searchpath of python, simply import the module and call the function:
import importlib
module = importlib.import_module(driver)
module.some_function()
Problem
I have some modules like this: ``` Drivers/ a.py b.py c.py ``` Now I want to call them on the basis of a variable value. let us consider driver is the variable from where I will get the variable name. ``` if driver=='a': #then call the driver a and execute. a.somefunction() if driver=='b': #then call the driver b and execute ``` I know the value we get from the driver in if statement is a string type value and in the if statement we have to call a module. is there any way to convert it.??