On this page
posixpath.relpath
Prev: posixpath.realpath | Up: posixpath | Next: posixpath.samefile
Rel: posixpath.abspath, posixpath.basename, posixpath.commonpath, posixpath.commonprefix
Ref: docs.python.org — posixpath.relpath
Tags: #public #python3 #stdlib #posixpath
Import
import posixpath
from posixpath import relpath
Signature & Overview
posixpath.relpath(path, start=None)
Return a relative version of a path
Usage
import posixpath
assert posixpath.relpath('/a/b/c', '/a') == 'b/c'
Gotchas
- Pure lexical calculation: Does not hit the filesystem unless
pathis relative.
REPL Inspect
from posixpath import relpath
help(relpath)
Linked from
Related notes
- tuts/python3/stdlib_module/posixpath/realpath Linked here; links to this page; shared tags: #posixpath, #stdlib
- tuts/python3/stdlib_module/posixpath/samefile Linked here; links to this page; shared tags: #posixpath, #stdlib
- tuts/python3/stdlib_module/posixpath Linked here; links to this page; shared tags: #stdlib
- tuts/python3/stdlib_module/posixpath/abspath Linked here; shared tags: #posixpath, #stdlib
- tuts/python3/stdlib_module/posixpath/basename Linked here; shared tags: #posixpath, #stdlib
- tuts/python3/stdlib_module/posixpath/commonpath Linked here; shared tags: #posixpath, #stdlib
- tuts/python3/stdlib_module/posixpath/commonprefix Linked here; shared tags: #posixpath, #stdlib
- tuts/python3/stdlib_module/posixpath/dirname shared tags: #posixpath, #stdlib
- tuts/python3/stdlib_module/posixpath/exists shared tags: #posixpath, #stdlib
- tuts/python3/stdlib_module/posixpath/expanduser shared tags: #posixpath, #stdlib