Silent the stdout of a function in python without trashing sys.stdout and restoring each function ca
- by Tim McJilton
Is there a way in python without wrapping a function call like following?
from sys import stdout
from copy import copy
tempstdout = copy(stdout)
stdout = file("trash",w)
foo()
stdout = tempstdout
That way works but appears to be terribly inefficient. There has to be a better way... I would appreciate any insight I can get into this.