How do you import a specified file into python 2.5?

Tuesday, July 8, 2014

In python, I have an input asking for a file to be imported, but it's response is that the "py" module isn't found. My main code is as follows:



package_to_be_loaded=raw_input("Type package to be loaded: ")
package=(package_to_be_loaded+"_install.py")
import package
package.run()


If you were to type TXTVIEWER into the input, it would import the file "TXTVIEWER_install.py", and take the function "run()" from it. My code in "TXTVIEWER_install.py" is as follows:



def run():
print("hello")


It's not working!







http://ift.tt/1xNy5Dq