Right now I am using the import command to run other python files. But, O want to be able to run a python file in a different folder. How could I do this?
EDIT: I am using execfile, no help needed!
Thanks for the help :)
Right now I am using the import command to run other python files. But, O want to be able to run a python file in a different folder. How could I do this?
EDIT: I am using execfile, no help needed!
Thanks for the help :)
For a quick and dirty way to import a module from a specified path, check out the imp
module: https://docs.python.org/2/library/imp.html
import imp
module_name = imp.load_source('module_name', '/path/to/module_name.py')
I'll write a short code to demonstrate:
import os
# change the directory
os.chdir('c:\dir1\dir2')
# use os to send commands to shell or dos
os.system('python program.py')
# you are done
Seriously, it's that easy!