You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I find Path.rel_path_to() method to be quite confusing. Consider the following example:
In [27]: %paste
from unipath import Path
p1 = Path('/a/b')
p2 = Path('/a/b/c/d')
print p1.rel_path_to(p2)
## -- End pasted text --
b/c/d
..
I do not quite understand why the first call returns b/c/d I would expect that the relative path of /a/b/c/d/ w.r.t. a/b is c/d. Indeed this is what pathlib yields:
In [39]: %paste
from pathlib2 import Path
p1 = Path('/a/b')
p2 = Path('/a/b/c/d')
print p2.relative_to(p1)
## -- End pasted text --
c/d
Note that the calling convention is also different: p2.relative_to(p1) is arguably more intuitive compared to p1.rel_path_to(p2).
The text was updated successfully, but these errors were encountered:
I find
Path.rel_path_to()
method to be quite confusing. Consider the following example:I do not quite understand why the first call returns
b/c/d
I would expect that the relative path of/a/b/c/d/
w.r.t.a/b
isc/d
. Indeed this is whatpathlib
yields:Note that the calling convention is also different:
p2.relative_to(p1)
is arguably more intuitive compared top1.rel_path_to(p2)
.The text was updated successfully, but these errors were encountered: