mirror of
https://github.com/python/cpython.git
synced 2025-08-04 08:59:19 +00:00
bpo-37689: add Path.is_relative_to() method (GH-14982)
This commit is contained in:
parent
8a784af750
commit
82642a052d
4 changed files with 111 additions and 1 deletions
|
@ -886,6 +886,15 @@ class PurePath(object):
|
|||
return self._from_parsed_parts('', root if n == 1 else '',
|
||||
abs_parts[n:])
|
||||
|
||||
def is_relative_to(self, *other):
|
||||
"""Return True if the path is relative to another path or False.
|
||||
"""
|
||||
try:
|
||||
self.relative_to(*other)
|
||||
return True
|
||||
except ValueError:
|
||||
return False
|
||||
|
||||
@property
|
||||
def parts(self):
|
||||
"""An object providing sequence-like access to the
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue