Problems with file.write()
John La Rooy
igetenoughspamalreadythanksjlr at doctor.com
Mon Sep 2 07:34:12 EDT 2002
Marc wrote:
>>Note that all buffered data is flushed automatically when you close()
>>an output file (you *are* closing the file, aren't you?).
>
>
> Actually I wasn't closing the file originally but it had never been a
> problem before. But closing the file now causes it to spill it's guts
> and gives me everything I was looking for.
>
> However, that doesn't explain why it wasn't working in the first
> place. I originally had it in unbuffered mode and wasn't getting all
> my text. As I increased the buffering from 1 to 2 I kept getting more
> text. But never all of it until I closed the file. It seems like it
> shouldn't be necessary to flush the buffer after every write if you're
> in unbuffered mode. This seems like a problem.
From the docs...
The optional bufsize argument specifies the file's desired buffer
size: 0 means unbuffered, 1 means line buffered, any other positive
value means use a buffer of (approximately) that size.
John
More information about the Python-list
mailing list