pathlib.PurePath.match()

PurePath.match(pattern) Match this path against the provided glob-style pattern. Return True if matching is successful, False otherwise. If pattern is relative, the path can be either relative or absolute, and matching is done from the right: >>> PurePath('a/b.py').match('*.py') True >>> PurePath('/a/b/c.py').match('b/*.py') True >>> PurePath('/a/b/c.py').match('a/*.py') False If pattern is absolute, the path must be absolute, and the whole path must match: >&g

pathlib.PurePath.joinpath()

PurePath.joinpath(*other) Calling this method is equivalent to combining the path with each of the other arguments in turn: >>> PurePosixPath('/etc').joinpath('passwd') PurePosixPath('/etc/passwd') >>> PurePosixPath('/etc').joinpath(PurePosixPath('passwd')) PurePosixPath('/etc/passwd') >>> PurePosixPath('/etc').joinpath('init.d', 'apache2') PurePosixPath('/etc/init.d/apache2') >>> PureWindowsPath('c:').joinpath('/Program Files') PureWindowsPath('c:/Program

pathlib.PurePath.is_reserved()

PurePath.is_reserved() With PureWindowsPath, return True if the path is considered reserved under Windows, False otherwise. With PurePosixPath, False is always returned. >>> PureWindowsPath('nul').is_reserved() True >>> PurePosixPath('nul').is_reserved() False File system calls on reserved paths can fail mysteriously or have unintended effects.

pathlib.PurePath.is_absolute()

PurePath.is_absolute() 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: >>> 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() Tr

pathlib.PurePath.drive

PurePath.drive A string representing the drive letter or name, if any: >>> PureWindowsPath('c:/Program Files/').drive 'c:' >>> PureWindowsPath('/Program Files/').drive '' >>> PurePosixPath('/etc').drive '' UNC shares are also considered drives: >>> PureWindowsPath('//host/share/foo.txt').drive '\\\\host\\share'

pathlib.PurePath.as_uri()

PurePath.as_uri() Represent the path as a file URI. ValueError is raised if the path isn’t absolute. >>> p = PurePosixPath('/etc/passwd') >>> p.as_uri() 'file:///etc/passwd' >>> p = PureWindowsPath('c:/Windows') >>> p.as_uri() 'file:///c:/Windows'

pathlib.PurePath.as_posix()

PurePath.as_posix() Return a string representation of the path with forward slashes (/): >>> p = PureWindowsPath('c:\\windows') >>> str(p) 'c:\\windows' >>> p.as_posix() 'c:/windows'

pathlib.PurePath.anchor

PurePath.anchor The concatenation of the drive and root: >>> PureWindowsPath('c:/Program Files/').anchor 'c:\\' >>> PureWindowsPath('c:Program Files/').anchor 'c:' >>> PurePosixPath('/etc').anchor '/' >>> PureWindowsPath('//host/share').anchor '\\\\host\\share\\'

pathlib.PurePath

class pathlib.PurePath(*pathsegments) A generic class that represents the system’s path flavour (instantiating it creates either a PurePosixPath or a PureWindowsPath): >>> PurePath('setup.py') # Running on a Unix machine PurePosixPath('setup.py') Each element of pathsegments can be either a string representing a path segment, or another path object: >>> PurePath('foo', 'some/path', 'bar') PurePosixPath('foo/some/path/bar') >>> PurePath(Path('foo'), Path('bar'

pathlib.PosixPath

class pathlib.PosixPath(*pathsegments) A subclass of Path and PurePosixPath, this class represents concrete non-Windows filesystem paths: >>> PosixPath('/etc') PosixPath('/etc') pathsegments is specified similarly to PurePath.