pathstring is a very small module that provides only one class
(pathstring.Path
) which is a string with support for path operations.
Technically, it subclasses str
and delegates path related operations to
pathlib.Path
.
Differences from pathlib paths are:
- Paths are strings, no need to cast them to strings.
- No distinction between "pure" and "concrete" paths.
- No explicit distinction between Posix and Windows paths, but paths are always "native" to their platform.
- Adds a
Path.rmtree()
method which invokesshutil.rmtree()
on the path. Actually, since paths are strings,shutil.rmtree(path)
will also work. - Supports the
walk_up
parameter to thePath.relative_to()
method which, when set toTrue
, will also navigate "up" in the hierarchy. - No support for case-insensitive comparisons on Windows.
- No
Path.replace()
method since it would cause confusion withstr.replace()
.
Features are tested extensively against pathlib documentation to guarantee compatibility.
Copyright (C) 2019-2024 H. Turgut Uyar <uyar@tekir.org>
pathstring is released under the BSD license. Read the included
LICENSE.txt
file for details.