Suppress Print Output in Python
Why? Sometimes you don’t want output at all to your screen, there are times when I’m writing a function that prints something to the screen, the ideal thing (at least for me) is to use return instead of print() of course, but let’s say that you don’t have another option and when it comes to Unit Testing it becomes annoying. How can we suppress STDOUT? Redirecting STDOUT We’re writing a simple script that greets someone:...