On Tuesday, 26.12.06 at 21:28, Steven D'Aprano wrote: > > # WARNING: untested > def run_without_stdout(*args, **kwargs): > function = args[0] > args = args[1:] > savestdout = sys.stdout > sys.stdout = cStringIO.StringIO() > result = None > try: > result = function(*args, **kwargs) > finally: > # don't forget to restore stdout, or you > # really will regret it... > sys.stdout = savestdout > return result >
There's no need for savestdout. There's a backup copy in sys.__stdout__ -Luis -- http://mail.python.org/mailman/listinfo/python-list