How Do You Deal With Print() Once You Done With Debugging/coding
Solution 1:
Use logging instead and here is why.
logging module comes with many simple & handy log methods like debug, info, warning, error, critical
ex:-
logging.debug(<debug stuff>)
EDIT
I am not sure I understood correctly about your need to disable logging once you are done, but if you want to do away with console logging you can try
#logger = logging.getLogger() # this gets the root logger
logger = logging.getLogger('my-logger')
logger.propagate = False
# now if you use logger it will not log to console.
EDIT
I think you want to remove all your print()/loggging statements from your code once you make sure everything is working fine!!!!
Try using a regx to comment out all print statements
find . -name '<filename>.py' -exec sed -ri "s/(^\s*)(print.*$)/#\1\2/g" {} \;
Solution 2:
You can use logging with debug level and once the debugging is completed, change the level to info. So any statements with logger.debug() will not be printed.
Solution 3:
What I do is put print statements in with with a special text marker in the string. I usually use print("XXX", thething)
. Then I just search for and delete the line with that string. It's also easier to spot in the output.
Post a Comment for "How Do You Deal With Print() Once You Done With Debugging/coding"