On Wed, 25 Jan 2017 at 05:26 Stephen J. Turnbull <
turnbull.stephen...@u.tsukuba.ac.jp> wrote:

> -1      I don't see how this is an improvement.  If it would raise if
>         exist_ok == False, then
>
>     try:
>         p.rename(another_p, exist_ok=False)
>     except ExistNotOKError:
>         take_evasive_action(p)
>
> doesn't seem like a big improvement over
>
>     if p.exists():
>         take_evasive_action(p)
>     else:
>         p.rename(another_p)
>
> And if it doesn't raise, then the action just silently fails?
>

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.
_______________________________________________
Python-ideas mailing list
Python-ideas@python.org
https://mail.python.org/mailman/listinfo/python-ideas
Code of Conduct: http://python.org/psf/codeofconduct/

Reply via email to