GeezerVisonThe World Wide Web, restored to 800 pixels of glory. | |||||||||||||||||||||||||||||||||||||||||||
| Home|About|Gaming cabinet|Archives|How it works|Starter sites | |||||||||||||||||||||||||||||||||||||||||||
GeezerVison is showing github.com — gh-77607: Rephrase documentation of os.path.join() by slateny · Pull Request #98995 · python/cpython Conversation
|
| a component is an absolute path, all previous components are thrown away | ||
| concatenation of *path* and any non-empty members of *\*paths* separated | ||
| by the platform's directory separator character. If the last member of *\*paths* | ||
| is empty, the result will end in the platform's directory separator. |
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
Made this part a bit more specific, but can use original suggested wording if wanted
| is empty, the result will end in the platform's directory separator. | |
| is empty, the result will end in a directory separator. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
If the last member of *paths
is empty, the result will end in the platform's directory separator.
It is not true. For example, os.path.join('', '') -> ''. On Windows, os.path.join('c:', '') -> 'c:'.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
That's a good point. Then perhaps instead, is empty, and if *path* is not a root dir or empty, then .... It can also be optionally less specific, and say, ... the result will generally end in the ....
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
It is problematic, because the term "root dir" needs explanation, especially on Windows.
What if just say that empty members are ignored, except the last one?
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
If it needs some explanation, then maybe we give a quick example and phrase it as "... and if path is a root directory (i.e., / or c:) or empty, then ..."
For your second statement, do you mean leaving out the note on platform separators? It seems a bit too noteworthy to leave it out though. It could be phrased differently like,
If the last element of paths is empty, the result will end in the platform's directory separator, unless path is empty or a root directory.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
I afraid that it would be too verbose and still not clear. It is not good place to introduce a new term, especially if it may conflict with the meaning in other sites.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
I see, you would prefer to keep it a bit vague, like The return value is the concatenation of *path* and any non-empty members of *paths* separated by the platform's directory separator character. Empty members of *paths* are ignored except for the last path. If a component is an absolute path, ...?
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
"end with the [...] separator" reads more naturally to me
Sorry, something went wrong.
There was an error while loading. Please reload this page.
| by the platform's directory separator character. If the last member of *\*paths* | ||
| is empty, the result will end in the platform's directory separator. |
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
@serhiy-storchaka Revisiting this, here's one alternative wording without introducing new terms:
| by the platform's directory separator character. If the last member of *\*paths* | |
| is empty, the result will end in the platform's directory separator. | |
| by the platform's directory separator character. If the last member of *\*paths* | |
| is empty, the result will usually end with the platform's directory separator. | |
| This does not happen in cases for certain values of *path*, such as ``'c:'`` | |
| on Windows. |
That would keep the idea of the original (but incorrect) note of the result will only end in a separator if the last part is empty. If dropping the note entirely is preferred, then I'll happily defer judgement here and in that case feel free to commit the below suggestion instead:
| by the platform's directory separator character. If the last member of *\*paths* | |
| is empty, the result will end in the platform's directory separator. | |
| by the platform's directory separator character. Empty members of *\*paths* | |
| are ignored except for the last path. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
There was overlap (and a merge conflict) with #100783. Serhiy's feedback applies to that change as well, so I'll open a new PR to fix. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
Successfully merging this pull request may close these issues.
There was an error while loading. Please reload this page.