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...
shell=Truedoesn't create a new window. It just means that the specified command will be executed through the shell. See docs.python.org/3/library/…shell=Truecauses the first argument to be converted to a string and used as an argument tosh -c. You don't wantshell=Trueif you are passing a list.