uos
– Filesystem functions
This module contains miscellaneous operating system functions.
Warning
All filesystem operations accept absolute paths only and will raise a
ValueError
when passed an invalid path.
Functions
- uos.listdir(path)
Obtain a list of names or the entries in the provided directory.
If the
path
is provided in typebytes
, the filenames returned are also of typebytes
; otherwise they are of typestr
.Note
The list is in an arbitrary order and does not include special entries such as
.
and..
, even if they are present in the directory. If a file is removed from or added to the directory during this function call, its appearance or otherwise is undetermined.- Parameters:
path (str or bytes) – Full path to the directory.
- Returns:
List containing the names of the entries in the directory.
- Return type:
str or bytes
- uos.mkdir(path, mode=None)
Create a directory.
- Parameters:
path (str) – Full path to the new directory.
mode (optional) – This parameter is ignored and is only present to ensure compatibility.
- Raises:
FileExistsError – Directory already exists.
- uos.remove(path)
Remove (delete) a file.
- Parameters:
path (str) – Full path to the file.
- Raises:
IsADirectoryError – The provided
path
is a directory rather than a file. Usermdir()
to remove directories.FileNotFoundError – File does not exist.
- uos.rmdir(path)
Remove (delete) a directory.
- Parameters:
path (str) – Full path to the directory.
- Raises:
FileNotFoundError – The directory does not exist.
OSError – Directory is not empty.