Search
 
SCRIPT & CODE EXAMPLE
 

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
Comment

PREVIOUS NEXT
Code Example
Python :: pandas perform action on column 
Python :: fine tune huggingface model pytorch 
Python :: algorithme pour afficher table de multiplication python 
Python :: how to remove zero after decimal float python 
Python :: pycharm display info of function 
Python :: range coding 
Python :: pandas df where 
Python :: python pass function as argument 
Python :: dictionary comprehension 
Python :: how to open an application with python 
Python :: get size of file python 
Python :: python remove list from nested list 
Python :: select specific columns in sqlalchemy 
Python :: sort one array based on another python 
Python :: cls in python 
Python :: create set in python 
Python :: check how many letters in a string python 
Python :: pyinstaller windows 
Python :: python create empty dictionary with keys 
Python :: tkinter change ttk button color 
Python :: python find if part of list is in list 
Python :: python dunder methods 
Python :: how to make capitalize text in python 
Python :: how to make python print 2 line text in one code 
Python :: inheritance in python 
Python :: arithmetic operators in python 
Python :: docstring python 
Python :: python default dictionary 
Python :: python sort a list by a custom order 
Python :: python input().strip() 
ADD CONTENT
Topic
Content
Source link
Name
7+2 =