non OO behaviour of file

Jp Calderone exarkun at divmod.com
Wed Jun 15 12:04:35 EDT 2005


On Wed, 15 Jun 2005 16:38:32 +0100, Robin Becker <robin at reportlab.com> wrote:
>Michael Hoffman wrote:
>.....
>>
>> Well, you could use python -u:
>>
>
>unfortunately this is in a detached process and I am just reopening stdout
>as an ordinary file so another process can do tail -F on it. I imagine ther
>ought to be an os dependant way to set the file as unbuffered, but can't
>remember/find out what it ought to be.
>

open(name, 'w', 0)

For even more excitment, there's os.open() with the O_DIRECT and O_SYNC flags.  You shouldn't need to go to this extreme, though.

FWIW, I think the behavior of Python wrt file subclasses that override write() is silly, too.

Jp



More information about the Python-list mailing list