Appending data to a json file

Grant Edwards grant.b.edwards at
Tue Apr 4 14:30:01 EDT 2017

On 2017-04-04, Ben Finney <ben+python at> wrote:
> Dave <dboland9 at> writes:
>> I don't care for the idea of replacing the data file for every save.
> This is the simplest implementation. It works. Can you say why you don't
> care for it?

After the data is read, it requires reloading the ASR33 with a fresh
spool of unpunched paper tape.

>> My preference would to append to the existing data file - makes
>> more sense.
> Can you expand on that? You haven't defined how that would satisfy the
> requirement, so it isn't clear to me why a more complex method “makes
> more sense” than the simple way which works now.

A big advantage to reading the old file and generating a complete new
file is that you can read the existing file, create a new temporary
file, and then 'rename(2)' the temporary file to replace the old one.

At least on Unix, rename is an filesystem-atomic operation and
provides a far smaller window of vulerability for r/w race conditions,
crash-induced problems, etc.  I assume there's a similar way to do
that under Windows...

Grant Edwards               grant.b.edwards        Yow! Mary Tyler Moore's
                                  at               SEVENTH HUSBAND is wearing
                                my DACRON TANK TOP in a
                                                   cheap hotel in HONOLULU!

More information about the Python-list mailing list