ID EN
Pathlib

is_absolute

Python 3.11

Return whether the path is absolute or not. A path is considered absolute if it has both a root and (if the flavour allows) a drive:

Syntax

PYTHON
PurePath.is_absolute()

Examples

Example 1
PYTHON
>>> PurePosixPath('/a/b').is_absolute()
True
>>> PurePosixPath('a/b').is_absolute()
False

>>> PureWindowsPath('c:/a/b').is_absolute()
True
>>> PureWindowsPath('/a/b').is_absolute()
False
>>> PureWindowsPath('c:').is_absolute()
False
>>> PureWindowsPath('//some/share').is_absolute()
True