ID EN
Pathlib

PurePath

Python 3.11

A generic class that represents the system’s path flavour (instantiating it creates either a PurePosixPath or a PureWindowsPath):

Syntax

PYTHON
class pathlib.PurePath(*pathsegments)

Examples

Example 1
PYTHON
>>> PurePath('setup.py')       Running on a Unix machine
PurePosixPath('setup.py')
Example 2
PYTHON
>>> PurePath('foo', 'some/path', 'bar')
PurePosixPath('foo/some/path/bar')
>>> PurePath(Path('foo'), Path('bar'))
PurePosixPath('foo/bar')
Example 3
PYTHON
>>> PurePath()
PurePosixPath('.')
Example 4
PYTHON
>>> PurePath('/etc', '/usr', 'lib64')
PurePosixPath('/usr/lib64')
>>> PureWindowsPath('c:/Windows', 'd:bar')
PureWindowsPath('d:bar')
Example 5
PYTHON
>>> PureWindowsPath('c:/Windows', '/Program Files')
PureWindowsPath('c:/Program Files')

See Also

PurePosixPath PureWindowsPath os.PathLike os.path.join() os.PathLike os.PathLike