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

Bruce Leban bruce at leapyear.org
Wed Aug 17 01:18:12 CEST 2011


On Tue, Aug 16, 2011 at 3:43 PM, Guido van Rossum <guido at python.org> wrote:

> Agreed. Also I think that in most cases the right thing to do is to
> quietly overwrite the file. If you're implementing a UI where you want
> look-before-you-leap, the app should code an explicit test so it can
> issue a proper error message (the exception will not be fun for the
> user :-).
>
>
This isn't look before you leap. It's catching a failure when the file can't
be created, just as you would if you don't have permission to write a file
in that directory or the file already exists and is locked so you don't have
permission to overwrite it. It just adds one more reason the file can't be
written. The app should already have code to translate those exceptions into
human-readable error messages so I don't think that's a good objection.

(If the implementation of this function in some OS needs LBYL then I think
that's an unfortunate defect in those OS.)

I've had enough working with programs that do things like silently eat
exceptions and I consider silently overwriting a file in the same class.

--- Bruce
Follow me: http://www.twitter.com/Vroo http://www.vroospeak.com
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-ideas/attachments/20110816/55c06105/attachment.html>


More information about the Python-ideas mailing list