I have a .py file and I want to make it so I can type it's name in another .py file and have it run all the code from the first file.
Remember, this is in Python 2.7 on a Raspberry Pi 3.
Thank you!
I have a .py file and I want to make it so I can type it's name in another .py file and have it run all the code from the first file.
Remember, this is in Python 2.7 on a Raspberry Pi 3.
Thank you!
Well you can use execfile() or os.system() to solve your problem. But I think, the correct way to tackle your problem is to import the file in your current script and call the imported file's functions or main function directly from your script.
Calling os.system("second.py")
or using subprocess.Popen
from you first script should work for you.