[Python-ideas] Add create mode to open()

Steven D'Aprano steve at pearwood.info
Wed Aug 17 12:40:51 CEST 2011

Benjamin Peterson wrote:
> Devin Jeanpierre <jeanpierreda at ...> writes:
>> LBYL is impossible here without a race condition, in fact, because the
>> situation can change between looking and leaping. An exception, or
>> else return code, is the only way. These can be checked for after the
>> fact.
> How often in this used? In every application I've written, writing a file
> usually results from the user giving a path, in which case it's intended to
> replace whatever is already there.

I frequently write scripts that, e.g. rename or move files with little 
or no human intervention. wget is a prime example of an application 
which needs to avoid overwriting files without human intervention, 
although I don't know how well it deals with race conditions.


More information about the Python-ideas mailing list