In Python, what is the shortest and the standard way of calling a command through subprocess
but not bothering with its output.
I tried subprocess.call
however it seems to return the output. I am not bothered with that, I just need to run the program silently without the output cluttering up the screen.
If it helps, I am callling pdflatex
and my intention is just to call it.
In case your process produces significant amounts of output that you don't want to buffer in memory, you should redirect the output to the electronic trash can:
with open(os.devnull, "w") as f:
subprocess.call(["pdflatex", filename], stdout=f)
The variable os.devnull
is the name of the null device of your operating system (/dev/null
on most OSes, nul
on the other one).