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

Bruce Leban bruce at leapyear.org
Wed Aug 17 02:12:25 CEST 2011

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

> So what's the use case? In general when using a command line
> environment overwriting the file is what you *want* to happen. Like
> with Unix "foo >bar". I don't even think there *is* a shell syntax for
> not overwriting an existing file, though you can use >> to append
> instead of overwrite -- this is open(filename, 'a').

We weren't just discussing command line tools. That said, I'm sure I'm not
the only person on this list who has inadvertently overwritten a file using
foo > bar. While we may have grown accustomed to this behavior and some
people (like you) may even consider it desirable, not everyone does.

> > 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.
> Always? How would you update an existing file if you can't overwrite files?

I didn't say never overwrite. What I don't like is programs overwriting
files without explicitly intending to do that.

Yes, there's a long legacy of overwriting files without warning or intent. I
suppose I'm fighting an uphill battle (and it's not my highest priority
complaint about bad code for that matter).

--- 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/dd8fad72/attachment.html>

More information about the Python-ideas mailing list