Serhiy Storchaka <[email protected]> added the comment:
It can be written as
try:
path.inlink()
except FileNotFoundError:
pass
If you want to save few lines of code, you can use contextlib.suppress().
with suppress(FileNotFoundError): path.inlink()
I suggest to close this issue. It is better to keep the API simple and
orthogonal. Adding an option in Path.unlink() will require adding this support
of this option in third-part implementations of Path. In general, adding a
single boolean parameter is not considered a good practice in Python.
A "strict" parameter in Path.resolve() does the different thing. In both cases
Path.resolve() returns a value, and you can't implement strict=False by
catching exception externally.
----------
nosy: +pitrou, serhiy.storchaka
_______________________________________
Python tracker <[email protected]>
<https://bugs.python.org/issue33123>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe:
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com