Importing a module, using a variable name?

Benjamin Schollnick junkster at nospam.rochester.rr.com
Thu Mar 9 21:11:07 EST 2000


Folks,

	Is it possible to import a module, via a variable?  I've tried it 
myself,
	and it doesn't seem possible.  Is there another "less obvious" method
	that would allow me to do roughly the same thing?

	Here's the example I tried:

		module_to_import = "test"
		import module_to_import

	I seem to remember a sys function to execute a python file, but
	would that allow me to access the functions, etc, in the file?

			- Benjamin


====================================================
          (Remove "NoSpam" to Email me)
====================================================
Please feel free to copy any and or all of this sig.
A little something for spam bots:

root at localhost postmaster at localhost admin at localhost
abuse at localhost postmaster at 127.0.0.1

Chairman William Kennard: bkennard at fcc.gov 
Commissioner Susan Ness: sness at fcc.gov
Commissioner Harold Furchtgott-Roth: hfurchtg at fcc.gov
Commissioner Michael Powell: mpowell at fcc.gov
Commissioner Gloria Tristani: gtristan at fcc.gov
consumerline at ftc.gov
fccinfo at fcc.gov
ssegal at fcc.gov




More information about the Python-list mailing list