Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bug in rel_path_to()? #21

Open
1pakch opened this issue Mar 10, 2015 · 0 comments
Open

Bug in rel_path_to()? #21

1pakch opened this issue Mar 10, 2015 · 0 comments

Comments

@1pakch
Copy link

1pakch commented Mar 10, 2015

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).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant