summaryrefslogtreecommitdiffstats
path: root/Doc/library/pathlib.rst
diff options
context:
space:
mode:
authorHai Shi <shihai1992@gmail.com>2019-08-13 19:54:02 (GMT)
committerAntoine Pitrou <antoine@python.org>2019-08-13 19:54:02 (GMT)
commit82642a052dc46b2180679518bc8d87e1a28a88b5 (patch)
tree8a987a065e51338c28d01dc359b404dc72717f0d /Doc/library/pathlib.rst
parent8a784af750fa82c8355903309e5089eb2b60c16b (diff)
downloadcpython-82642a052dc46b2180679518bc8d87e1a28a88b5.zip
cpython-82642a052dc46b2180679518bc8d87e1a28a88b5.tar.gz
cpython-82642a052dc46b2180679518bc8d87e1a28a88b5.tar.bz2
bpo-37689: add Path.is_relative_to() method (GH-14982)
Diffstat (limited to 'Doc/library/pathlib.rst')
-rw-r--r--Doc/library/pathlib.rst15
1 files changed, 14 insertions, 1 deletions
diff --git a/Doc/library/pathlib.rst b/Doc/library/pathlib.rst
index 166de8d..33fac5f 100644
--- a/Doc/library/pathlib.rst
+++ b/Doc/library/pathlib.rst
@@ -273,7 +273,7 @@ Methods and properties
.. testsetup::
- from pathlib import PurePosixPath, PureWindowsPath
+ from pathlib import PurePath, PurePosixPath, PureWindowsPath
Pure paths provide the following methods and properties:
@@ -462,6 +462,19 @@ Pure paths provide the following methods and properties:
True
+.. method:: PurePath.is_relative_to(*other)
+
+ Return whether or not this path is relative to the *other* path.
+
+ >>> p = PurePath('/etc/passwd')
+ >>> p.is_relative_to('/etc')
+ True
+ >>> p.is_relative_to('/usr')
+ False
+
+ .. versionadded:: 3.9
+
+
.. method:: PurePath.is_reserved()
With :class:`PureWindowsPath`, return ``True`` if the path is considered