View Full Version : Python Question
30th May 2004, 03:33 PM
Is there a way you can have the user input something and have the module import a module with the name of the input.
Hope that makes sense. Any help appreciated. :(
30th May 2004, 04:50 PM
I don't know. Have you checked the documentation (http://www.python.org/doc/)?
30th May 2004, 05:35 PM
Interesting question.. got me fiddling anyways : )
newmodule = raw_input("Module to load: ")
mymodule = __import__ (newmodule)
So, for example, if the user inputted "sys" to load the sys module, you'd use..
30th May 2004, 07:42 PM
Thank you that worked perfectly! :-D
vBulletin® v3.8.7, Copyright ©2000-2013, vBulletin Solutions, Inc.