def suppress_output(fn):
 save_stdout = sys.stdout
 try:
  sys.stdout = DummyFile()
  fn()
 finally:
  sys.stdout = save_stdout

def suppress_output ( fn ) : save_stdout = sys . stdout try : sys . stdout = DummyFile ( ) fn ( ) finally : sys . stdout = save_stdout
suppresses the output of fn on sys .