Skip to main content

os.path

Standard library Module View source

Native path operations (POSIX, or Windows when targeting win32).

variable curdir
curdir: Literal[str] = "."
variable pardir
pardir: Literal[str] = ".."
variable extsep
extsep: Literal[str] = "."
function exists
exists(path: str) -> bool
function lexists
lexists(path: str) -> bool
function isfile
isfile(path: str) -> bool
function isdir
isdir(path: str) -> bool
function samefile
samefile(path1: str, path2: str) -> bool
function sameopenfile
sameopenfile(fd1: int, fd2: int) -> bool
function getsize
getsize(path: str) -> int
function getmtime
getmtime(path: str) -> float
function getatime
getatime(path: str) -> float
function getctime
getctime(path: str) -> float
function expanduser
expanduser(path: str) -> str
function realpath
realpath(path: str, *, strict: bool = False) -> str
function isabs
isabs(path: str) -> bool
function join
join(a: str, *paths) -> str
function split
split(path: str) -> Tuple[(str, str)]
function dirname
dirname(path: str) -> str
function basename
basename(path: str) -> str
function splitdrive
splitdrive(path: str) -> Tuple[(str, str)]
function splitroot
splitroot(path: str) -> Tuple[(str, str, str)]
function normcase
normcase(path: str) -> str
function normpath
normpath(path: str) -> str
function abspath
abspath(path: str) -> str
function relpath
relpath(path: str, start: str = ".") -> str
function commonprefix
commonprefix(paths) -> str
function commonpath
commonpath(paths) -> str
function expandvars
expandvars(path: str) -> str
function splitext
splitext(p: str) -> Tuple[(str, str)]

Split a pathname into (root, ext).

The extension runs from the last dot to the end, ignoring leading dots.
`ext` may be empty.