path - Work with paths

class path.Path(value, separator=None)

Path instances can be created from strings, other Path instances or tuples. If separator is not specified, the one from the OS is used. Once created, paths can be manipulated like a tuple, each element being an element of the path. It makes a few common operations easy, such as getting the filename (path[-1]) or the directory name or parent (path[:-1]).

HS apps pretty much always refer to Path instances when a variable name ends with path. If a variable is of another type, that type is usually explicited in the name.

To make common operations (from os.path, os and shutil) convenient, the io module wraps these functions and converts paths to strings.

Previous topic

misc - Miscellaneous utilities

Next topic

str - String utilities

This Page