On this page
ntpath.relpath
Prev: ntpath.realpath | Up: ntpath | Next: ntpath.samefile
Rel: ntpath.abspath, ntpath.basename, ntpath.commonpath, ntpath.commonprefix
Ref: docs.python.org — ntpath.relpath
Tags: #public #python3 #stdlib #ntpath
Import
import ntpath
from ntpath import relpath
Signature & Overview
ntpath.relpath(path, start=None)
Return a relative version of a path
Usage
import ntpath
assert ntpath.relpath(r'C:\a\b\c', r'C:\a') == r'b\c'
Gotchas
- Raises
ValueErroracross different Windows drive letters.
REPL Inspect
from ntpath import relpath
help(relpath)
Linked from
Related notes
- tuts/python3/stdlib_module/ntpath/realpath Linked here; links to this page; shared tags: #ntpath, #stdlib
- tuts/python3/stdlib_module/ntpath/samefile Linked here; links to this page; shared tags: #ntpath, #stdlib
- tuts/python3/stdlib_module/ntpath Linked here; links to this page; shared tags: #stdlib
- tuts/python3/stdlib_module/ntpath/abspath Linked here; shared tags: #ntpath, #stdlib
- tuts/python3/stdlib_module/ntpath/basename Linked here; shared tags: #ntpath, #stdlib
- tuts/python3/stdlib_module/ntpath/commonpath Linked here; shared tags: #ntpath, #stdlib
- tuts/python3/stdlib_module/ntpath/commonprefix Linked here; shared tags: #ntpath, #stdlib
- tuts/python3/stdlib_module/ntpath/dirname shared tags: #ntpath, #stdlib
- tuts/python3/stdlib_module/ntpath/exists shared tags: #ntpath, #stdlib
- tuts/python3/stdlib_module/ntpath/expanduser shared tags: #ntpath, #stdlib