suppress print() function in python modules

Viewed 46

I'm building a multi module python program

in each module i have some function where i used to print some output during debugging of each individual module

while calling modules's functions in the main program body those print function issues output

How I can suppress these print output ?

1 Answers

One solution is to use the Logging class (https://docs.python.org/3/library/logging.html) provided by python. By using logging.debug instead of print for class debug messages, if the logging level in main is above debug (>10), then these debug messages will not be displayed.

Related