@contextmanager<EOL>def redirect_output(fileobj):
old = sys.stdout<EOL>sys.stdout = fileobj<EOL>try:<EOL><INDENT>yield fileobj<EOL><DEDENT>finally:<EOL><INDENT>sys.stdout = old<EOL><DEDENT>
Redirect standard out to file.