Errors should never pass silently ... unless explicitly silenced.

Dave Brueck dave at pythonapocrypha.com
Fri Feb 7 17:24:40 CET 2003


On Fri, 7 Feb 2003, Michele Simionato wrote:

> In Linux I am doing
>
>   sys.stderr=file('/dev/null','w')
>
> Is there a better way of doing that? I would be interested in a portable
> way, valid for Windows too.

Hi Michele,

How about:

class FakeFile:
  def write(*args): pass

sys.stderr = FakeFile()

-Dave





More information about the Python-list mailing list