Title: Clarify os.path.join documentation · Issue #100783 · python/cpython · GitHub
Open Graph Title: Clarify os.path.join documentation · Issue #100783 · python/cpython
X Title: Clarify os.path.join documentation · Issue #100783 · python/cpython
Description: https://docs.python.org/3/library/os.path.html#os.path.join On Windows, the drive letter is not reset when an absolute path component (e.g., r'\foo') is encountered. If a component contains a drive letter, all previous components are thr...
Open Graph Description: https://docs.python.org/3/library/os.path.html#os.path.join On Windows, the drive letter is not reset when an absolute path component (e.g., r'\foo') is encountered. If a component contains a drive...
X Description: https://docs.python.org/3/library/os.path.html#os.path.join On Windows, the drive letter is not reset when an absolute path component (e.g., r'\foo') is encountered. If a component contains...
Opengraph URL: https://github.com/python/cpython/issues/100783
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Clarify os.path.join documentation","articleBody":"https://docs.python.org/3/library/os.path.html#os.path.join\r\n\r\n\u003e On Windows, the drive letter is not reset when an absolute path component (e.g., r'\\foo') is encountered. If a component contains a drive letter, all previous components are thrown away and the drive letter is reset. Note that since there is a current directory for each drive, os.path.join(\"c:\", \"foo\") represents a path relative to the current directory on drive C: (c:foo), not c:\\foo.\r\n\r\nThere are a couple potential issues here.\r\n\r\nFirst, it should be \"drive\", not \"drive letter\":\r\n```\r\n\u003e\u003e\u003e ntpath.join(\"thrownaway\", \"//host/computer/dir\", \"/asdf\") # unc is not a letter\r\n'//host/computer/asdf'\r\n```\r\n\r\nSecond, it should be \"if a component is from a different drive or an absolute path, all previous components are thrown away and the drive is reset\":\r\n```\r\n\u003e\u003e\u003e ntpath.join(\"C:\", \"foo\", \"C:\", \"bar\") # previous components are not thrown away\r\n'C:foo\\\\bar'\r\n\u003e\u003e\u003e ntpath.join(\"C:\", \"foo\", \"D:\", \"bar\")\r\n'D:bar'\r\n```\r\n\r\nThird, as a nit, maybe \"component\" should be replaced with \"segment\", since arguments can contain path separators. This would improve consistency with the pathlib docs.\r\n\r\ncc @barneygale @JelleZijlstra \r\n\r\nThese came up in https://github.com/python/cpython/pull/100782\n\n\u003c!-- gh-linked-prs --\u003e\n### Linked PRs\n* gh-100811\n* gh-100843\n* gh-100844\n\u003c!-- /gh-linked-prs --\u003e\n","author":{"url":"https://github.com/hauntsaninja","@type":"Person","name":"hauntsaninja"},"datePublished":"2023-01-06T01:08:41.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":0},"url":"https://github.com/100783/cpython/issues/100783"}
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:4bb367c2-e7cc-95df-845e-93cb84e5dbaa |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | C868:2265AE:3600F0:4ADB1E:696A73E7 |
| html-safe-nonce | 936d02e51bef3acc32e8a44703c76838686af0d273f0d6502ec9bfd9a730ce08 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJDODY4OjIyNjVBRTozNjAwRjA6NEFEQjFFOjY5NkE3M0U3IiwidmlzaXRvcl9pZCI6IjE2MzU2MjE4OTg1NDE0OTUyNzEiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ== |
| visitor-hmac | 0de13fca96d0800bf5522afe7f11a32c8d684b6c546a058ee3df95279c36b005 |
| hovercard-subject-tag | issue:1521700284 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/python/cpython/100783/issue_layout |
| twitter:image | https://opengraph.githubassets.com/4535c0e2970e02a921f892886df099e5ba5560272e4318f5e84e74ee052106d4/python/cpython/issues/100783 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/4535c0e2970e02a921f892886df099e5ba5560272e4318f5e84e74ee052106d4/python/cpython/issues/100783 |
| og:image:alt | https://docs.python.org/3/library/os.path.html#os.path.join On Windows, the drive letter is not reset when an absolute path component (e.g., r'\foo') is encountered. If a component contains a drive... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | hauntsaninja |
| hostname | github.com |
| expected-hostname | github.com |
| None | cfa223d62d272274e0b68350b4bd7741f3ca7498b8c4b8b1bc1e6deabbdbc09d |
| turbo-cache-control | no-preview |
| go-import | github.com/python/cpython git https://github.com/python/cpython.git |
| octolytics-dimension-user_id | 1525981 |
| octolytics-dimension-user_login | python |
| octolytics-dimension-repository_id | 81598961 |
| octolytics-dimension-repository_nwo | python/cpython |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 81598961 |
| octolytics-dimension-repository_network_root_nwo | python/cpython |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | 6a0b6893c221f98f607598e939299fdf5763435d |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width