portable /dev/null

Gabriel Genellina gagsl-py2 at yahoo.com.ar
Fri May 2 15:45:11 EDT 2008


En Fri, 02 May 2008 16:20:04 -0300, Brendan Miller <catphive at catphive.net>  
escribió:

> I have functions that take a file object and write to it. In some cases I
> just want to throw out what is written to that file object. I want
> something like open('/dev/null', 'w'), but portable.
>
> It needs to have an underlying file descriptor/file handle, as it will be
> passed to non python code.
>
> Is there a portable /dev/null somewhere in the standard library?

py> import os
py> print os.devnull
nul

(this is on Windows)

-- 
Gabriel Genellina




More information about the Python-list mailing list