portable /dev/null

Brendan Miller catphive at catphive.net
Fri May 2 17:45:16 EDT 2008


On Fri, 02 May 2008 21:41:36 +0200, Christian Heimes wrote:

> 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

Awesome. Thanks.

Brendan



More information about the Python-list mailing list