I was wondering how I would redirect the output of a program I would run with subprocess.Popen to the program I am using. For example, if I’m executing a script from Python ImageProcessing.py in.jpeg out.jpeg, I would like to instead do some extra processing in the higher level script; meaning that I would like the python code to replace out.jpeg with a pipe or some other sort of communication. (Also, yes I know it would be better to import in most cases, in this case I rather not).
Thank you in advance!
You can use the
stdout=subprocess.PIPEargument toPopen. The stdout of the subprocess is a normal file. Example: