Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork33.7k
gh-101000: Add os.path.splitroot()#101002
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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
Merged
+279 −165
Merged
Changes from1 commit
Commits
Show all changes
31 commits Select commitHold shift + click to select a range
21c0ba9 gh-101000: Add os.path.splitroot()
barneygale836b85d Use splitroot() from pathlib
barneygalebc2d1f9 Use splitroot() from posixpath
barneygaleecdc40d Use splitroot() from ntpath
barneygale6592b27 Optimizations
barneygale78f4227 Correct and expand examples in splitroot() docstring
barneygale9726ca4 Update Lib/ntpath.py
barneygale7a6613c Use splitroot() from pathlib.PurePath.with_name()
barneygale26a8dba Reduce ntpath.normpath() diff noise
barneygale0c237d4 Simplify ntpath.commonpath() now that 'isabs' is unused.
barneygale11ed3eb Reduce posixpath.normpath() diff noise
barneygale2c9eed8 Improve documentation
barneygale8299e96 Add whatsnew entry.
barneygale27ffe37 Simplify ntpath.splitroot() slightly
barneygale9beff2a Apply suggestions from code review
barneygalebacdee1 Update Doc/library/os.path.rst
barneygale4ebe545 Note that drive may be empty on Windows
barneygale2927afe Re-order drive example
barneygaleb0aa73e Update Doc/library/os.path.rst
barneygale19777d6 Adjust docstring examples
barneygale32e212e Apply suggestions from code review
barneygale37cded3 Update Doc/library/os.path.rst
barneygale5a8dfce Change example username in docs to 'Sam'
barneygale0e75a55 Adjust first paragraph to use prose
barneygale3663237 Update Doc/library/os.path.rst
barneygale053729d Add tests for bytes (POSIX only) and path-like objects (both platforms)
barneygale694f093 Add tests for mixed path separators (Windows only)
barneygalee99e3cd Remove errant newline.
barneygalef618a00 Move most test cases from `test_splitdrive` to `test_splitroot`
barneygale1c522c9 Mention pathlib performance improvement in news entry.
barneygaledf17269 Merge branch 'main' into gh-101000-splitroot
AlexWaygoodFile filter
Filter by extension
Conversations
Failed to load comments.
Loading
Uh oh!
There was an error while loading.Please reload this page.
Jump to
Jump to file
Failed to load files.
Loading
Uh oh!
There was an error while loading.Please reload this page.
Diff view
Diff view
Change example username in docs to 'Sam'
- Loading branch information
Uh oh!
There was an error while loading.Please reload this page.
commit5a8dfce4e15db8cac619637ec2344134547fc540
There are no files selected for viewing
20 changes: 10 additions & 10 deletionsDoc/library/os.path.rst
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -502,21 +502,21 @@ the :mod:`glob` module.) | ||
| <https://pubs.opengroup.org/onlinepubs/9699919799/basedefs/V1_chap04.html#tag_04_13>`_.) | ||
| For example:: | ||
| >>> splitroot('/home/sam') | ||
| ('', '/', 'home/sam') | ||
| >>> splitroot('//home/sam') | ||
| ('', '//', 'home/sam') | ||
| >>> splitroot('///home/sam') | ||
| ('', '/', '//home/sam') | ||
| On Windows, *drive* may be empty, a drive-letter name, a UNC share, or a device | ||
| name. The *root* may be empty, a forward slash, or a backward slash. For | ||
| example:: | ||
| >>> splitroot('C:/Users/Sam') | ||
| ('C:', '/', 'Users/Sam') | ||
| >>> splitroot('//Server/Share/Users/Sam') | ||
| ('//Server/Share', '/', 'Users/Sam') | ||
| In all cases, ``drive + root + tail`` will be the same as *path*. | ||
barneygale marked this conversation as resolved. OutdatedShow resolvedHide resolvedUh oh!There was an error while loading.Please reload this page. | ||
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.