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
ortable.
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
--
http://mail.python.org/mailman/listinfo/python-list
ndle, as it will be
> passed to non python code.
>
> Is there a portable /dev/null somewhere in the standard library?
The subprocess module should work fine. Pass a pipe to the subprocess,
and read and discard anything from the pipe (e.g. in a separate thread).
If the non-Python code is inpro
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
--
http://
;), 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?
>
> Thanks,
> Brendan
I don't think so. You could define a dummy class emulating the
passed to non python code.
Is there a portable /dev/null somewhere in the standard library?
Thanks,
Brendan
--
http://mail.python.org/mailman/listinfo/python-list