/dev/null as a file-like object, or logging to nothing

Torsten Bronger bronger at physik.rwth-aachen.de
Sat Sep 8 19:42:14 CEST 2007


Hallöchen!

Marc 'BlackJack' Rintsch writes:

> On Sat, 08 Sep 2007 18:52:57 +0200, Torsten Bronger wrote:
>
>> Is there a portable and simply way to direct file-like IO to
>> simply nothing?  I try to implement some sort of NullLogging by
>> saying
>
> `os.devnull`?

Yes, but I wasn't really sure how portable it is, in particular, on
Windows.  So does

open(os.devnull, "w").write("Schallalla")

work on Windows like on Unix?

Tschö,
Torsten.

-- 
Torsten Bronger, aquisgrana, europa vetus
                                      Jabber ID: bronger at jabber.org
                      (See http://ime.webhop.org for ICQ, MSN, etc.)



More information about the Python-list mailing list