Reputation: 2845
How would I go about opening a file in Python by referring to a text file. EXAMPLE:
f.open('openthis.txt')
Then I would have openthis.txt in the same folder that would say:
C:\Folder\myprogram.exe
Therefore the code opens up myprogram.exe from the directory
I want to do this so the code is easily changable, instead of having to edit it in IDLE every time I want to change the file I open.
Upvotes: 0
Views: 210
Reputation: 627
You want the subprocess module. Specifically, you'd do something like:
import subprocess
with open("inputfile", "rb") as f:
subprocess.call(f.read())
Upvotes: 1