0

I have two files main.py& test.py Suppose the main file main.py is running and after a point of time I want to run test.py I cannot use: import test or os.system("python test.py") because this run python file in same terminal but I want to run the test.py in other terminal

So I mean to say in one terminal main.py is running after a point a new terminal opens and run test.py

Any solutions? Thanks :D

1 Answers1

0

If I understand correctly you want to run a python script when some condition is fulfilled so I would recommend calling the "test.py" using a subprocess library (bear in mind there are other methods) like this:

import subprocess
if(your_condition):
  subprocess.call(['python', 'test.py', testscript_arg1, testscript_val1,...])

as mentioned here: Using a Python subprocess call to invoke a Python script

Krzysztof
  • 1
  • 1