MCPcopy Index your code
hub / github.com/python/cpython / redirect_stdout

Class redirect_stdout

Lib/contextlib.py:411–424  ·  view source on GitHub ↗

Context manager for temporarily redirecting stdout to another file. # How to send help() to stderr with redirect_stdout(sys.stderr): help(dir) # How to write help() to a file with open('help.txt', 'w') as f: with redirect_stdout(f):

Source from the content-addressed store, hash-verified

409
410
411class redirect_stdout(_RedirectStream):
412 """Context manager for temporarily redirecting stdout to another file.
413
414 # How to send help() to stderr
415 with redirect_stdout(sys.stderr):
416 help(dir)
417
418 # How to write help() to a file
419 with open('help.txt', 'w') as f:
420 with redirect_stdout(f):
421 help(pow)
422 """
423
424 _stream = "stdout"
425
426
427class redirect_stderr(_RedirectStream):

Callers 5

test_file_faultMethod · 0.90
do_testMethod · 0.90
do_integration_testMethod · 0.90

Calls

no outgoing calls

Tested by 5

test_file_faultMethod · 0.72
do_testMethod · 0.72
do_integration_testMethod · 0.72

Used in the wild real call sites across dependent graphs

searching dependent graphs…