<div dir="ltr"><div class="gmail_quote"><div dir="ltr">On Wed, 25 Jan 2017 at 05:26 Stephen J. Turnbull <<a href="mailto:turnbull.stephen.fw@u.tsukuba.ac.jp">turnbull.stephen.fw@u.tsukuba.ac.jp</a>> wrote:</div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
-1 I don't see how this is an improvement. If it would raise if<br class="gmail_msg">
exist_ok == False, then<br class="gmail_msg">
<br class="gmail_msg">
try:<br class="gmail_msg">
p.rename(another_p, exist_ok=False)<br class="gmail_msg">
except ExistNotOKError:<br class="gmail_msg">
take_evasive_action(p)<br class="gmail_msg">
<br class="gmail_msg">
doesn't seem like a big improvement over<br class="gmail_msg">
<br class="gmail_msg">
if p.exists():<br class="gmail_msg">
take_evasive_action(p)<br class="gmail_msg">
else:<br class="gmail_msg">
p.rename(another_p)<br class="gmail_msg">
<br class="gmail_msg">
And if it doesn't raise, then the action just silently fails?<br class="gmail_msg"></blockquote><div><br></div><div>The latter should be if another_p.exists(), and it can race with the creation of another_p—this is a textbook motivating example for EAFP.</div></div></div>