portable /dev/null again

John Belmonte john at neggie.net
Wed Mar 24 19:20:04 CET 2004


Hello,

A few months ago, someone suggested the need for a portable equivalent 
to /dev/null in Python's libraries.  He was told it was too trivial an 
addition to the library, and to use something like:

     class nullFile:
         def write(self, data):
             pass

However, as the above does not present a full Python file object, it 
can't go everywhere that say, sys.stdout can go.  More specifically, it 
doesn't provide a file descriptor that may be required by low-level 
interfaces.

I wish an os.nullfile (or at least, os.nullfilename) was available so 
that I wouldn't have to think about this.

-John Belmonte


-- 
http:// if  ile.org/




More information about the Python-list mailing list