I have a python code that should execute another code in some other file.
For reasons I don't have the time to explain now I need to use the subprocess
-module or something similar. My fuction should use any window in which the print
- commands in my second file should give their output. Here are my files:
maincode.py:
#import subprocess
def startFileInNewProcess(filename):
proc = subprocess.Popen(["python", filename], shell=True)
startFileInNewProcess("mysecondfile.py")
mysecondfile.py:
import os
print os.getcwd()
As far as I undestood some articles on SO, the parameter shell=True
should create a new window with the output of the mysecondfile.py
. This does not happen! Can anybody explain why and please give improvement proposals...