Does os.path relpath produce an incorrect relative path?

Eryk Sun eryksun at gmail.com
Fri May 26 11:42:01 EDT 2023


On 5/26/23, cactus <riemannic at gmail.com> wrote:
>
> Surprisingly (for me at least) the alternative provided by the pathlib
> module 'relative_to' method doesn't provide for full relative path
> computation.  I was expecting this would offer everything that os.path
> offers but it doesn't in this case.

Starting with Python 3.12, the relative_to() method has a walk_up
parameter. It defaults to False for the sake of backward
compatibility.

https://docs.python.org/3.12/library/pathlib.html#pathlib.PurePath.relative_to


More information about the Python-list mailing list