Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

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
AlexWaygood merged 31 commits intopython:mainfrombarneygale:gh-101000-splitroot
Jan 27, 2023
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()
barneygaleJan 12, 2023
836b85d
Use splitroot() from pathlib
barneygaleJan 12, 2023
bc2d1f9
Use splitroot() from posixpath
barneygaleJan 12, 2023
ecdc40d
Use splitroot() from ntpath
barneygaleJan 12, 2023
6592b27
Optimizations
barneygaleJan 12, 2023
78f4227
Correct and expand examples in splitroot() docstring
barneygaleJan 13, 2023
9726ca4
Update Lib/ntpath.py
barneygaleJan 13, 2023
7a6613c
Use splitroot() from pathlib.PurePath.with_name()
barneygaleJan 14, 2023
26a8dba
Reduce ntpath.normpath() diff noise
barneygaleJan 15, 2023
0c237d4
Simplify ntpath.commonpath() now that 'isabs' is unused.
barneygaleJan 15, 2023
11ed3eb
Reduce posixpath.normpath() diff noise
barneygaleJan 15, 2023
2c9eed8
Improve documentation
barneygaleJan 15, 2023
8299e96
Add whatsnew entry.
barneygaleJan 15, 2023
27ffe37
Simplify ntpath.splitroot() slightly
barneygaleJan 15, 2023
9beff2a
Apply suggestions from code review
barneygaleJan 16, 2023
bacdee1
Update Doc/library/os.path.rst
barneygaleJan 16, 2023
4ebe545
Note that drive may be empty on Windows
barneygaleJan 16, 2023
2927afe
Re-order drive example
barneygaleJan 16, 2023
b0aa73e
Update Doc/library/os.path.rst
barneygaleJan 16, 2023
19777d6
Adjust docstring examples
barneygaleJan 18, 2023
32e212e
Apply suggestions from code review
barneygaleJan 19, 2023
37cded3
Update Doc/library/os.path.rst
barneygaleJan 19, 2023
5a8dfce
Change example username in docs to 'Sam'
barneygaleJan 19, 2023
0e75a55
Adjust first paragraph to use prose
barneygaleJan 19, 2023
3663237
Update Doc/library/os.path.rst
barneygaleJan 22, 2023
053729d
Add tests for bytes (POSIX only) and path-like objects (both platforms)
barneygaleJan 22, 2023
694f093
Add tests for mixed path separators (Windows only)
barneygaleJan 22, 2023
e99e3cd
Remove errant newline.
barneygaleJan 22, 2023
f618a00
Move most test cases from `test_splitdrive` to `test_splitroot`
barneygaleJan 22, 2023
1c522c9
Mention pathlib performance improvement in news entry.
barneygaleJan 22, 2023
df17269
Merge branch 'main' into gh-101000-splitroot
AlexWaygoodJan 22, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
PrevPrevious commit
NextNext commit
Improve documentation
  • Loading branch information
@barneygale
barneygale committedJan 15, 2023
commit2c9eed88823e840d8b39a34b26ae0e63f0a9fe38
26 changes: 19 additions & 7 deletionsDoc/library/os.path.rst
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -492,16 +492,28 @@ the :mod:`glob` module.)

Split the pathname *path* into a triad ``(drive, root, tail)`` where:

1. *drive* isan optionalmount point, exactly like :func:`splitdrive`;
2. *root* isan optionalsequence of separators following the drive; and
1. *drive* isamount point or the empty string;
2. *root* isasequence of separators following the drive or the empty string; and
3. *tail* is anything after the root.

On Posix, *drive* is always empty. The *root* may be empty (relative path),
a single forward slash (absolute path), or two forward slashes
(implementation-defined per the POSIX standard).
On POSIX systems, *drive* is always empty. The *root* may be empty (if *path* is
relative), a single forward slash (if *path* is absolute), or two forward slashes
(implementation-defined per `IEEE Std 1003.1 2013 Edition; 4.13 Pathname Resolution
<https://pubs.opengroup.org/onlinepubs/9699919799/basedefs/V1_chap04.html#tag_04_13>`_.)
For example::

On Windows, *drive* may be a UNC sharepoint or a traditional DOS drive. The
*root* may be empty, a forward slash, or a backward slash.
>>> splitroot('/etc/hosts')
('', '/', 'etc/hosts')

On Windows, *drive* may be a UNC sharepoint or a traditional drive-letter drive. The
*root* may be empty, a forward slash, or a backward slash. For example::

>>> splitroot('//server/share/')
('//server/share', '/', '')
>>> splitroot('C:/Users/Barney')
('C:', '/', 'Users/Barney')
>>> splitroot('Windows/notepad')
('', '', 'Windows/notepad')

In all cases, ``drive + root + tail`` will be the same as *path*.

Expand Down

[8]ページ先頭

©2009-2025 Movatter.jp