I’m having a problem with my python script.
It’s printing massive amounts of data on the screen, and I would like to prevent all sorts of printing to screen.
Edit:
The library I’m using is mechanize, and it’s printing a LOT of data on screen.
I have set these to false with no luck!
br.set_debug_redirects(False)
br.set_debug_responses(False)
br.set_debug_http(False)
Any ideas?
Help would be amazing and very much appreciated!
(Based on your 2nd edit)
If you don’t want to disable all output, you can try to be specific to
mechanizeitself. http://wwwsearch.sourceforge.net/mechanize/ provides a snippet, which I’ve modified (though I’m not sure if it will work):When you print something it goes to the screen through the
sys.stdoutfile. You can change this file to any other file (eg, a log file you open) so that nothing is printed to the screen:Of course, if you’re talking about some library that you’re calling, it may be printing to
sys.stderr. Luckily, you can do the exact same thing for this one (continuing from above):Now if, for some reason, you want to completely ignore stdout (or stderr) and never see it again, you can define your own file-like classes that simply discard the objects:
And, to add to the din of possible solutions, here is a solution that works in Unix shells: