How can one open a file for exclusive access?

Parzival Herzog parz at shaw.SpamBucket.ca
Mon Jan 14 12:09:33 EST 2002


I am using Python 2.1 under Windows 2000.

I want to be able to open a file for writing exclusively,
that while it is open, no other process may read or
write to that file.

I find that any number of processes can

    open("c:/temp/foo","w")

leading to (predictably) unpredictable results.

I had imagined that such exclusive access was
automatically provided by the OS, but I seem to be
mistaken.

So, how, in Python, can one open a file for exclusive
access?

- Parzival





More information about the Python-list mailing list