[Python-ideas] pathlib suggestions
Ed Kellett
edk141 at gmail.com
Wed Jan 25 07:09:36 EST 2017
On Wed, 25 Jan 2017 at 05:26 Stephen J. Turnbull <
turnbull.stephen.fw at 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.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-ideas/attachments/20170125/be5287fe/attachment-0001.html>
More information about the Python-ideas
mailing list