Message321822
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. |
|
Date |
User |
Action |
Args |
2018-07-17 13:10:28 | serhiy.storchaka | set | recipients:
+ serhiy.storchaka, pitrou, lordmauve, rbu |
2018-07-17 13:10:28 | serhiy.storchaka | set | messageid: <1531833028.02.0.56676864532.issue33123@psf.upfronthosting.co.za> |
2018-07-17 13:10:28 | serhiy.storchaka | link | issue33123 messages |
2018-07-17 13:10:27 | serhiy.storchaka | create | |
|