On 2023-02-19 12:59:43 -0500, Thomas Passin wrote: > On 2/19/2023 11:57 AM, Axy via Python-list wrote: > > Looks like the data to be written is buffered, so actual write takes > > place after readlines(), when close() flushes buffers. > > > > See io package documentation, BufferedIOBase. > > > > The solution is file.flush() after file.write() > > Another possibility, from the Python docs: > > "...TextIOWrapper (i.e., files opened with mode='r+') ... To disable > buffering in TextIOWrapper, consider using the write_through flag for > io.TextIOWrapper.reconfigure()"
That actually doesn't help (I tried it before writing my answer). The
binary layer below the text layer also buffers ...
> Also from the docs:
>
> "Warning: Calling f.write() without using the with keyword or calling
> f.close() might result in the arguments of f.write() not being completely
> written to the disk, even if the program exits successfully."
He does call file.close():
> > > file.close()
so that doesn't seem relevant.
hp
--
_ | Peter J. Holzer | Story must make more sense than reality.
|_|_) | |
| | | [email protected] | -- Charles Stross, "Creative writing
__/ | http://www.hjp.at/ | challenge!"
signature.asc
Description: PGP signature
-- https://mail.python.org/mailman/listinfo/python-list
