Python Forum

Full Version: how to open program file .exe from list
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
here is my code
    if mybuffer == "b'Open'":
        print("Program is Opening")
        your_Po = (r'C:\Qt\5.13.1\mingw73_32\bin\designer.exe')
        fp = os.popen(your_Po) #use os.popen for get out from loop
but if i have 3 program with different path how I can open it with list of my 3 path of program?

like this your_Po = ('C:\Qt\5.13.1\mingw73_32\bin\designer.exe' , 'C:\Qt\5.13.1\mingw73_32\bin\designer1.exe',
'C:\Qt\5.13.1\mingw73_32\bin\designer2.exe')

Huh
Make a list and loop.
Use subprocess and not os.popen().
Example.
import subprocess

run_lst = [
    r"C:\Qt\5.13.1\mingw73_32\bin\designer.exe",
    r"C:\Qt\5.13.1\mingw73_32\bin\designer1.exe",
    r"C:\Qt\5.13.1\mingw73_32\bin\designer2.exe",
]

processes = [subprocess.Popen([cmd]) for cmd in run_lst]
Thank you