@contextmanager<EOL>def replace_print(fileobj=sys.stderr):
printer = _Printer(fileobj)<EOL>previous_stdout = sys.stdout<EOL>sys.stdout = printer<EOL>try:<EOL><INDENT>yield printer<EOL><DEDENT>finally:<EOL><INDENT>sys.stdout = previous_stdout<EOL><DEDENT>
Sys.out replacer, by default with stderr.

    Use it like this:
    with replace_print_with(fileobj):
      print "hello"  # writes to the file
    print "done"  # prints to stdout

    Args:
      fileobj: a file object to replace stdout.

    Yields:
      The printer.