Mojo module
path
Implements the os.path operations.
You can import these APIs from the os.path
package. For example:
from os.path import isdir
from os.path import isdir
Functions
-
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 inpath
to the user's home directory. -
expandvars
: Replaces${var}
or$var
in 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. -
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. -
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. -
splitroot
: Splitspath
into 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!