New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
bpo-44316: add keep_curdir
and keep_pardir
arguments to os.path.normpath()
#26694
Conversation
When set to `True`, `..` entries are retained, which ensures the path's meaning is preserved in the presence of symlinks. This functionality was previously available only in pathlib.
strict
argument to os.path.normpath
strict
argument to os.path.normpath()
strict
argument to os.path.normpath()
keep_curdir
and keep_pardir
arguments to os.path.normpath()
This PR is stale because it has been open for 30 days with no activity. |
Hello Barney, Would the fix in this commit help solve the question mentioned here : https://stackoverflow.com/questions/62687193/how-to-create-a-pathlib-relative-path-with-a-dot-starting-point ? Was curious to know if the code changes for this Pull Request were ever added to the main code ? |
By design, pathlib normalizes
I'd like to make this customizable in a future edition of pathlib, but it's a ways off yet. The code in this PR hasn't landed anywhere, and probably won't given there's now a C version of the same function. |
Thanks Barney. I was finding it hard to understand why a leading dot like I hope that this gets addressed. I am assuming that, as of now, |
In many cases it is spurious, e.g. And pathlib should support that, eventually, IMO. For now I recommend you use strings and |
I agree that pathlib should support a leading dot since it is a valid case for executing a shell command. I was almost on the verge of implementing On a side note, may be the reason for pathlib to worry so much about spurious items in a path, is a fall out of the code trying to fix a negative test case and missing out on a valid positive scenario ( of shell scripts ). May be pathlib should have left the decision about spurious dots to the application ( shell globbing in the case of the |
Retaining '..' entries ensures the path's meaning is preserved in the presence of symlinks. This functionality was previously available only in pathlib.
Retaining '.' entries helps ensure shells don't interpret paths differently (compare
./python
andpython
). Thanks to @eryksun for the suggestion.https://bugs.python.org/issue44316