i can silence and restore sys.stdout this way:
sys.stdout
import sys sys.stdout = None print(\'hello\') # does not write to stdout sys.stdout = sys.__stdo
print has an explicit check for None.
/* sys.stdout may be None when FILE* stdout isn't connected */ if (file == Py_None) Py_RETURN_NONE;