fo.flush() & fo.write() on windows

Sam Schulenburg samschul at pacbell.net
Mon Aug 30 00:11:50 EDT 1999


An advantage of opining and closing the file to force flushing is, another
process can access the file. I use this to allow other users to view the log
files's that I create while runnig a test.

Sam Schulenburg

Roberts, Robert J <robert_j_roberts at rl.gov> wrote in message
news:37C9C25F.DE0BEEAB at rl.gov...
> Am I asking too much?
>
> pseudo code:
>
>     fo = __builtin__.open(foName, 'a')
>     foSize = os.stat(foName)[6]     # if foSize = 100...
>     fo.write('Some string.')             # fo.write() returns None
>     foSize = os.stat(foName)[6]    # ...foSize STILL = 100.
>     fo.flush()
>     foSize = os.stat(foName)[6]    # ...foSize STILL = 100.
>     fo.close()                                # 'Some string' appears in
> fo.
>     foSize = os.stat(foName)[6]    # foSize = foSize + 'Some string' #
> of bytes.
>
> I am running Python 1.5.2 on Windows 95. fo.write() appears to be
> buffering the write and returning None for bytes written on fo.write().
> fo.flush() appears to do nothing.
>
> ...or... am I missing something?
>
>






More information about the Python-list mailing list