PyDocs

Nav

File and Directory Access

PurePath

pathlib

class (source)
  • PurePath(*pathsegments)
Base class for manipulating paths without I/O.

PurePath represents a filesystem path and offers operations which
don't imply any actual filesystem I/O.  Depending on your system,
instantiating a PurePath will return either a PurePosixPath or a
PureWindowsPath object.  You can also instantiate either of these classes
directly, regardless of your system.
Changed in 3.6
  • 3.6: Added support for the os.PathLike interface.
Members of PurePath

a

anchor
The concatenation of the drive and root, or ''.
as_posix
Return the string representation of the path with forward (/) slashes.

d

drive
The drive prefix (letter or UNC path), if any.

f

full_match
Return True if this path matches the given glob-style pattern.

i

is_absolute
True if the path is absolute (has both a root and, if applicable, a drive).
is_relative_to
Return True if the path is relative to another path or False.

j

joinpath
Combine this path with one or several arguments, and return a new path representing either a subpath (if all arguments are relative paths) or a totally different path (if one of the arguments is anch…

m

match
Return True if this path matches the given pattern.

n

name
The final path component, if any.

p

parent
The logical parent of the path.
parents
A sequence of this path's logical parents.
parser
Common operations on Posix pathnames.
parts
An object providing sequence-like access to the components in the filesystem path.

r

relative_to
Return the relative path to another path identified by the passed arguments.
root
The root of the path, if any.

s

stem
The final path component, minus its last suffix.
suffix
The final component's last suffix, if any.
suffixes
A list of the final component's suffixes, if any.

w

with_name
Return a new path with the file name changed.
with_segments
Construct a new path object from any number of path-like objects.
with_stem
Return a new path with the stem changed.
with_suffix
Return a new path with the file suffix changed.
1 Example
>>> PurePath('setup.py')      # Running on a Unix machine
PurePosixPath('setup.py')
from the Python docs
See Also
No see-alsos for pathlib/PurePath
0 Notes
No notes for PurePath