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

Nick Coghlan ncoghlan at gmail.com
Wed Aug 17 05:42:59 CEST 2011

On Wed, Aug 17, 2011 at 12:10 PM, Calvin Spealman <ironfroggy at gmail.com> wrote:
> While there are plenty of responders debating how unix-y or sensible
> this is from the standpoint of other languages or precedents, I think
> this makes sense from the standpoint of new users and a fresh
> viewpoints. Creating a new file is a very sensible thing to want in a
> single operation.

Yes, this suggestion came out of the shutil.move discussion, precisely
*because* it is so hard to write a platform-independent, multi-process
safe operation that will reliably either create a new file or else
throw an exception if the file already exists, or if the underlying
filesystem doesn't provide the necessary primitives to provide the
appropriate guarantees. I don't think it needs to be added to the open
builtin, but a shutil function specifically for this operation
certainly sounds like a reasonable request.


Nick Coghlan   |   ncoghlan at gmail.com   |   Brisbane, Australia

More information about the Python-ideas mailing list