Remove output of all subprocesses in Python without access to code
问题 In Python I'm using sys.stdout = None before some calls that I don't control. These calls may call some subprocesses that write to stdout. How can I avoid this subprocesses calls to write to stdout? Again, I don't have ownership of the code that calls the subprocess. It seems subprocess.Popen (and similar) doesn't honor sys.stdout. 回答1: You could replace subprocess.Popen with a custom function that suppresses stdout and stderr : import subprocess import inspect def Popen(*args, **kwargs): sig