To shut up in Python, you can redirect the standard output and error streams to a null device using the subprocess
module and os.devnull
constant.
main.py206 chars10 lines
This will run some_command
without printing any output to the console. The with
statement opens /dev/null
as a file object with write permissions, and passes it as the stdout
and stderr
arguments to subprocess.call()
, which will redirect the output of the command to the null device.
gistlibby LogSnag