<div><font class="Apple-style-span" face="arial, helvetica, sans-serif"><br></font></div><div class="gmail_quote">On Tue, Aug 16, 2011 at 3:43 PM, Guido van Rossum <span dir="ltr"><<a href="mailto:guido@python.org">guido@python.org</a>></span> wrote:<br>

<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;"><div class="im">Agreed. Also I think that in most cases the right thing to do is to</div>
quietly overwrite the file. If you're implementing a UI where you want<br>
look-before-you-leap, the app should code an explicit test so it can<br>
issue a proper error message (the exception will not be fun for the<br>
user :-).<br><font class="Apple-style-span" color="#888888"><br></font></blockquote><div><br></div><div>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.</div>

<div><br></div><div>(If the implementation of this function in some OS needs LBYL then I think that's an unfortunate defect in those OS.)</div><div><br></div><div>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.</div>

</div><div><br clear="all"><font face="arial, helvetica, sans-serif">--- Bruce</font><div><font face="arial, helvetica, sans-serif">Follow me: <a href="http://www.twitter.com/Vroo" target="_blank">http://www.twitter.com/Vroo</a> <a href="http://www.vroospeak.com/" target="_blank">http://www.vroospeak.com</a></font></div>

</div><div><br></div>