Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PYTHON

python suppress print output from function

import contextlib
import io
import sys

@contextlib.contextmanager
def nostdout():
    save_stdout = sys.stdout
    sys.stdout = io.BytesIO()
    yield
    sys.stdout = save_stdout
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #python #suppress #print #output #function
ADD COMMENT
Topic
Name
9+2 =