-
-
Save ruxi/7ff2d14a4e4f98f14165b5834c656fe5 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment