diff options
author | Hai Shi <shihai1992@gmail.com> | 2019-08-13 19:54:02 (GMT) |
---|---|---|
committer | Antoine Pitrou <antoine@python.org> | 2019-08-13 19:54:02 (GMT) |
commit | 82642a052dc46b2180679518bc8d87e1a28a88b5 (patch) | |
tree | 8a987a065e51338c28d01dc359b404dc72717f0d /Doc/library/pathlib.rst | |
parent | 8a784af750fa82c8355903309e5089eb2b60c16b (diff) | |
download | cpython-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.rst | 15 |
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 |