Serhiy Storchaka added the comment:

>>> from pathlib import Path
>>> p = Path('/foo/bar')
>>> Path('/foo') in p.parents
True
>>> Path('/spam') in p.parents
False
>>> p.parts[:2] == ('/', 'foo')
True
>>> p.parts[:2] == ('/', 'spam')
False
>>> p.relative_to('/foo')
PosixPath('bar')
>>> p.relative_to('/spam')
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/lib/python3.5/pathlib.py", line 864, in relative_to
    .format(str(self), str(formatted)))
ValueError: '/foo/bar' does not start with '/spam'

----------
nosy: +serhiy.storchaka

_______________________________________
Python tracker <rep...@bugs.python.org>
<http://bugs.python.org/issue28560>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to