I want to create a function which uses import, like the following:
def test_module(module_name):
try:
import module_name
except ImportError:
print 'import '+module_name+' error'
test_module('os')
however, the function doesn't work because import seems not to recognize the string variable. are there any workarounds?
thanks!