[issue25012] pathlib should allow converting to absolute paths without resolving symlinks
David Barnett
report at bugs.python.org
Tue Sep 8 01:21:29 CEST 2015
David Barnett added the comment:
The idiom of
pathlib.Path.cwd() / pathlib.Path('some/path')
isn't too bad of an approach if it could just be mentioned in the docs. I would intuitively expected something like
pathlib.Path('some/path').resolve(follow_symlinks=False)
My use case was that I had an equality check like this failing:
expected_path = pathlib.Path.cwd() / pathlib.Path('some/path')
pathlib.Path('some/path') == expected_path
I suppose I should file that as a separate bug because semantically those paths are equal, but I was trying to work around it like
pathlib.Path('some/path').resolve() == expected_path
which in my case still failed because some/path was a symlink.
Even if that's fixed, I would still expect to run into cases where I wanted to print specifically the relative or absolute path in informational messages and would not want to follow symlinks (e.g., in "Requested path X not found", the user would recognize the absolute path as the one they entered but not necessarily the symlink-resolved version).
----------
_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue25012>
_______________________________________
More information about the Python-bugs-list
mailing list