Python menekan output cetak dari fungsi
with nostdout():
foo()
Busy Boar
with nostdout():
foo()
import contextlib
import io
import sys
@contextlib.contextmanager
def nostdout():
save_stdout = sys.stdout
sys.stdout = io.BytesIO()
yield
sys.stdout = save_stdout