summaryrefslogtreecommitdiffstats
path: root/Doc/library/os.path.rst
diff options
context:
space:
mode:
Diffstat (limited to 'Doc/library/os.path.rst')
-rw-r--r--Doc/library/os.path.rst33
1 files changed, 33 insertions, 0 deletions
diff --git a/Doc/library/os.path.rst b/Doc/library/os.path.rst
index 42bbe24..786c2fd 100644
--- a/Doc/library/os.path.rst
+++ b/Doc/library/os.path.rst
@@ -488,6 +488,39 @@ the :mod:`glob` module.)
Accepts a :term:`path-like object`.
+.. function:: splitroot(path)
+
+ Split the pathname *path* into a 3-item tuple ``(drive, root, tail)`` where
+ *drive* is a device name or mount point, *root* is a string of separators
+ after the drive, and *tail* is everything after the root. Any of these
+ items may be the empty string. In all cases, ``drive + root + tail`` will
+ be the same as *path*.
+
+ 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-2017; 4.13 Pathname Resolution
+ <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')
+
+ .. versionadded:: 3.12
+
+
.. function:: splitext(path)
Split the pathname *path* into a pair ``(root, ext)`` such that ``root + ext ==