Suppress output to stdout/stderr in InteractiveInterpreter

Robert Kern robert.kern at gmail.com
Thu Apr 15 19:03:09 EDT 2010


On 2010-04-15 17:54 PM, Dave W. wrote:
>>                                  After your reply, I went back and
>> discovered that everything was actually working fine with 'global'
>> in place<snip>
>
> Oops, I lied.  It still doesn't work.  It doesn't seem possible (or
> at least not easy) to *globally* override the built-in print
> function.  The best I've managed to do is override it for the
> current module.
>
> Think I'll start a new post with the subject: "Globally override
> built-in print function?"

Don't bother. Replacing sys.stdout is the right thing to do. It won't interfere 
with the C++ streams but it will take care of some potential Python output that 
does not go through the print() function.

-- 
Robert Kern

"I have come to believe that the whole world is an enigma, a harmless enigma
  that is made terrible by our own mad attempt to interpret it as though it had
  an underlying truth."
   -- Umberto Eco




More information about the Python-list mailing list