portable /dev/null

Christian Heimes lists at cheimes.de
Fri May 2 15:41:36 EDT 2008


Brendan Miller schrieb:
> Hi,
> 
> 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.

import os
null = open(os.devnull, "wb")

:)

Christian



More information about the Python-list mailing list