Reputation: 893
I am looking to open a Python script in edit mode in IDLE by passing in a directory from another Python script. I understand that I can use os.system
to execute idle.py but I then don't know how to pass the appropriate -e
parameter and get it to use a specific directory i.e. open something.py in diredtory C:\Python all from the original Python script.
Thanks for your help,
Ben
Upvotes: 1
Views: 143
Reputation: 7657
You can use subprocess.call()
. By setting shell = True
, the function treats the string as a literal shell command. Modify the paths as you see fit.
import subprocess
subprocess.call(r'C:\Python27\Lib\idlelib\idle.py -e C:\Python27\something.py',
shell=True)
Upvotes: 2