Closed as not planned
Description
Feature or enhancement
Proposal:
Because we have os.path.exists()
& os.path.lexists()
, it might make sense to add a follow_symlinks
argument to the former:
-def exists(path):
+def exists(path, *, follow_symlinks=True):
"""Test whether a path exists. Returns False for broken symbolic links"""
try:
- os.stat(path)
+ os.stat(path, follow_symlinks=follow_symlinks)
except (OSError, ValueError):
return False
return True
This matches pathlib.Path.exists()
(as well as os.stat()
& os.chmod()
).Also, it looks like (but that's less explicit and so unnecessary, see #21157 (comment))pathlib.Path
doesn't have an lexists()
function.
Note: this argument also needs to be added to Done.nt._path_exists()
.
Has this already been discussed elsewhere?
This is a minor feature, which does not need previous discussion elsewhere
Links to previous discussion of this feature:
No response