Skip to content Skip to sidebar Skip to footer

Python: Pass Sys.argv When Loading Python Script With Subprocess.popen

I have a script that opens a file using subprocess.Popen so I can run it in the background. I would like to be able to run this script with ./[script] [params] #!/usr/bin/python im

Solution 1:

Just forward/concatenate the arguments in the subprocess.Popen() call:

if __name__ == "__main__":
    subprocess.Popen(["python", "./pyqt/gui.py"] + sys.argv[1:])

Post a Comment for "Python: Pass Sys.argv When Loading Python Script With Subprocess.popen"