[Tutor] Passing a variable to 'import'

Chris Keelan rufmetal@rogers.com
Wed, 19 Dec 2001 23:17:30 -0500

I have a piece of code like so:


def import_module(someModule):
	import someModule

Of course that gives me the following output:

Traceback (most recent call last):
  File "<stdin>", line 1, in import_module
ImportError: No module named moduleName

So how do I, for example, grab a module name from sys.argv and then pass it 
to the import command as a variable?

- Chris