-2

I have a python (.py) script. I want to add a code to run guideType.py on gui.py script. When I opening the program it runs gui.py. So I want to be executing that guideType.py when it starts

gui.py = http://d-h.st/UsZY

guideType.py = http://d-h.st/7SNF

Anthon
  • 69,918
  • 32
  • 186
  • 246

3 Answers3

0

You can do import of the script, that would cause the statements in that script get executed.

import gui
Anand S Kumar
  • 88,551
  • 18
  • 188
  • 176
0

Try using os.system("python guideType.py") when you want to execute the second python script. Otherwise, subprocess here might help you achieve what you are asking.

Anand S Kumar
  • 88,551
  • 18
  • 188
  • 176
0

Try something like this

import os, sys

path_python_exec = sys.executable
path_exec_file = ''

command = '%s %s'%(path_python_exec, path_exec_file)
os.system(command)

Customize it according to your needs.

Yogeesh Seralathan
  • 1,396
  • 4
  • 15
  • 22