Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PYTHON

python redirect console output to devnull

from contextlib import contextmanager
import sys, os

@contextmanager
def suppress_stdout():
    with open(os.devnull, "w") as devnull:
        old_stdout = sys.stdout
        sys.stdout = devnull
        try:  
            yield
        finally:
            sys.stdout = old_stdout
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #python #redirect #console #output #devnull
ADD COMMENT
Topic
Name
3+4 =