rel-path

Get relative path.


License
MIT
Install
pip install rel-path==1.0.1

Documentation

relpath - relative path module

Python package GitHub license

This module eliminates a weakness of pathlib.Path. The class Path returns ValueError if the relative-path is not a subdirectory of the base-path.

Installation

pip install rel-path

Example for error:

from pathlib import Path

base="/home"
rel="/"

# Error when using Path
Path(rel).relative_to(base)

Exception has occurred: ValueError
'/' does not start with '/home'

Example using relpath module:

from relpath import relative_path

base="/home"
rel="/"

print(relative_path(base, rel))
../

Support

If you find any problems with relpath module, please report them to GitHub, and I will respond when possible. Code contributions are always welcome, and ideas for new modules, or additions to existing modules, are also appreciated.