Mojo module
path
Provides a set of operating-system independent functions for manipulating file system paths.
You can import these APIs from the os.path package. For example:
from os.path import isdirFunctions
-
basename: Returns the tail section of a path. -
dirname: Returns the directory component of a pathname. -
exists: Return True if path exists. -
expanduser: Expands a tilde "~" prefix inpathto the user's home directory. -
expandvars: Replaces${var}or$varin the path with values from the current environment variables. Malformed variable names and references to non-existing variables are left unchanged. -
getsize: Return the size, in bytes, of the specified path. -
is_absolute: Return True ifpathis an absolute path name. On Unix, that means it begins with a slash. -
isdir: Return True if path is an existing directory. This follows symbolic links, so both islink() and isdir() can be true for the same path. -
isfile: Test whether a path is a regular file. -
islink: Return True if path refers to an existing directory entry that is a symbolic link. -
join: Join two or more pathname components, inserting '/' as needed. If any component is an absolute path, all previous path components will be discarded. An empty last part will result in a path that ends with a separator. -
lexists: Return True if path exists or is a broken symlink. -
realpath: Expands all symbolic links and resolves references to /./, /../ and extra '/' characters in the null-terminated string named by path to produce a canonicalized absolute pathname.The resulting path will have no symbolic link, /./ or /../ components. -
split: Split a given pathname into two components: head and tail. This is useful for separating the directory path from the filename. If the input path ends with a separator, the tail component will be empty. If there is no separator in the path, the head component will be empty, and the entire path will be considered the tail. Trailing separators in the head are stripped unless the head is the root directory. -
split_extension: Splitspathinto the root and extension. -
splitroot: Splitspathinto drive, root and tail. The tail contains anything after the root.
Was this page helpful?
Thank you! We'll create more content like this.
Thank you for helping us improve!