-
-
Notifications
You must be signed in to change notification settings - Fork 31.9k
Incorrect details for os.path.abspath()
documentation
#130527
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
Comments
EDIT: See #130527 (comment) cc @barneygale |
os.path.abspath()
documentationos.path.abspath()
documentation
Even that would then still be a bit wrong or at least misleading, cause |
Oh and one should probably cross check that with what the non POSIX versions of this function actually do, cause the POSIX one makes the check for absoluteness via checking for a leading |
Actually, I think I was wrong.
So, |
So, we wouldn't have "every absolute pathname would get the cwd prepended." |
Indeed. But then the original text is actually correct (albeit still confusing IMO, though mainly because |
Yes, but that's how it's been for years so I don't think we can change this =/ So while it could be confusing, we shouldn't forget about Now, what we could however do is highlight more that part on the WDYT @barneygale? Also, do you know why it was chosen that absolute segments make previous segments ignored? |
Sure. The only alternative would be a I guess from the |
I'm not sure we need this kind of function in the stdlib, at least not until someone demonstrates that it's a common pattern that well-known libraries would want. It can be implemented by a utility helper but I don't think it's a function to include. |
I'm however still concerned about the fact that we refer to a function in the docs before it has been documented and without any clickable link to it so I guess we can still update the docs of |
I think I'm going to close this one an open a separate issue for reorganizing the |
The behavior is pretty logical IMO. This function operates on paths, not strings. An absolute path can't be joined relative to another path as it is, in fact, absolute and refers absolutely to some location. It doesn't matter whether you calculate the location of I use this notion extensively in build systems. For example the Meson Build System exposed this directly as a DSL function, It's also natively what pathlib objects do including for the div overload. So I would regard it as highly surprising to suspect that anyone would not recognize what it's doing. If what you actually wanted was string joining, that exists. os.path.normpath(a + '/' + b) Or don't care about the doubled forward slashes and skip the normpath (the join function won't normalize literal components with preexisting forward slashes). |
Well, this issue isn't really about the behaviour of But anyway... it is as it is and software may already depend on that (IMO: mis)feature. |
Yeah, I'll repeat that my software considers it a brilliant, intuitive, and highly useful feature and as such I depend on this. |
In case it's helpful, I imagine that
|
Documentation
cpython/Doc/library/os.path.rst
Lines 59 to 61 in 3a555f0
claim is wrong, because
normpath(join(os.getcwd(), path))
is only called when the pathname is not absolute.If the claim would be true, every absolute pathname would get the cwd prepended.
Cheers,
Chris.
The text was updated successfully, but these errors were encountered: