Alex Rivera | Logout

Silence loggers and printing to screen - Python

Asked 2010-04-09T04:39:57.513
14

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!

Edit
Report

1 Answer

0

you can use the StringIO module, too, instead of rolling your own stdout stream. Occasionally, the stdout needs more than a write method (flush is another common one), which StringIO will handle.

import StringIO
import sys

sys.stdout = StringIO.StringIO()
answered 2010-04-09T05:58:04.937

Your Answer