File and Directory Access
*************************

The modules described in this chapter deal with disk files and
directories.  For example, there are modules for reading the
properties of files, manipulating paths in a portable way, and
creating temporary files.  The full list of modules in this chapter
is:

* "pathlib" — Object-oriented filesystem paths

  * Basic use

  * Exceptions

    * "UnsupportedOperation"

  * Pure paths

    * "PurePath"

    * "PurePosixPath"

    * "PureWindowsPath"

    * General properties

    * Operators

    * Accessing individual parts

      * "parts"

    * Methods and properties

      * "parser"

      * "drive"

      * "root"

      * "anchor"

      * "parents"

      * "parent"

      * "name"

      * "suffix"

      * "suffixes"

      * "stem"

      * "as_posix()"

      * "is_absolute()"

      * "is_relative_to()"

      * "is_reserved()"

      * "joinpath()"

      * "full_match()"

      * "match()"

      * "relative_to()"

      * "with_name()"

      * "with_stem()"

      * "with_suffix()"

      * "with_segments()"

  * Concrete paths

    * "Path"

    * "PosixPath"

    * "WindowsPath"

    * Parsing and generating URIs

      * "from_uri()"

      * "as_uri()"

    * Expanding and resolving paths

      * "home()"

      * "expanduser()"

      * "cwd()"

      * "absolute()"

      * "resolve()"

      * "readlink()"

    * Querying file type and status

      * "stat()"

      * "lstat()"

      * "exists()"

      * "is_file()"

      * "is_dir()"

      * "is_symlink()"

      * "is_junction()"

      * "is_mount()"

      * "is_socket()"

      * "is_fifo()"

      * "is_block_device()"

      * "is_char_device()"

      * "samefile()"

    * Reading and writing files

      * "open()"

      * "read_text()"

      * "read_bytes()"

      * "write_text()"

      * "write_bytes()"

    * Reading directories

      * "iterdir()"

      * "glob()"

      * "rglob()"

      * "walk()"

    * Creating files and directories

      * "touch()"

      * "mkdir()"

      * "symlink_to()"

      * "hardlink_to()"

    * Renaming and deleting

      * "rename()"

      * "replace()"

      * "unlink()"

      * "rmdir()"

    * Permissions and ownership

      * "owner()"

      * "group()"

      * "chmod()"

      * "lchmod()"

  * Pattern language

  * Comparison to the "glob" module

  * Comparison to the "os" and "os.path" modules

    * Corresponding tools

* "os.path" — Common pathname manipulations

  * "abspath()"

  * "basename()"

  * "commonpath()"

  * "commonprefix()"

  * "dirname()"

  * "exists()"

  * "lexists()"

  * "expanduser()"

  * "expandvars()"

  * "getatime()"

  * "getmtime()"

  * "getctime()"

  * "getsize()"

  * "isabs()"

  * "isfile()"

  * "isdir()"

  * "isjunction()"

  * "islink()"

  * "ismount()"

  * "isdevdrive()"

  * "isreserved()"

  * "join()"

  * "normcase()"

  * "normpath()"

  * "realpath()"

  * "relpath()"

  * "samefile()"

  * "sameopenfile()"

  * "samestat()"

  * "split()"

  * "splitdrive()"

  * "splitroot()"

  * "splitext()"

  * "supports_unicode_filenames"

* "fileinput" — Iterate over lines from multiple input streams

  * "input()"

  * "filename()"

  * "fileno()"

  * "lineno()"

  * "filelineno()"

  * "isfirstline()"

  * "isstdin()"

  * "nextfile()"

  * "close()"

  * "FileInput"

  * "hook_compressed()"

  * "hook_encoded()"

* "stat" — Interpreting "stat()" results

  * "S_ISDIR()"

  * "S_ISCHR()"

  * "S_ISBLK()"

  * "S_ISREG()"

  * "S_ISFIFO()"

  * "S_ISLNK()"

  * "S_ISSOCK()"

  * "S_ISDOOR()"

  * "S_ISPORT()"

  * "S_ISWHT()"

  * "S_IMODE()"

  * "S_IFMT()"

  * "filemode()"

  * "ST_MODE"

  * "ST_INO"

  * "ST_DEV"

  * "ST_NLINK"

  * "ST_UID"

  * "ST_GID"

  * "ST_SIZE"

  * "ST_ATIME"

  * "ST_MTIME"

  * "ST_CTIME"

  * "S_IFSOCK"

  * "S_IFLNK"

  * "S_IFREG"

  * "S_IFBLK"

  * "S_IFDIR"

  * "S_IFCHR"

  * "S_IFIFO"

  * "S_IFDOOR"

  * "S_IFPORT"

  * "S_IFWHT"

  * "S_ISUID"

  * "S_ISGID"

  * "S_ISVTX"

  * "S_IRWXU"

  * "S_IRUSR"

  * "S_IWUSR"

  * "S_IXUSR"

  * "S_IRWXG"

  * "S_IRGRP"

  * "S_IWGRP"

  * "S_IXGRP"

  * "S_IRWXO"

  * "S_IROTH"

  * "S_IWOTH"

  * "S_IXOTH"

  * "S_ENFMT"

  * "S_IREAD"

  * "S_IWRITE"

  * "S_IEXEC"

  * "UF_SETTABLE"

  * "UF_NODUMP"

  * "UF_IMMUTABLE"

  * "UF_APPEND"

  * "UF_OPAQUE"

  * "UF_NOUNLINK"

  * "UF_COMPRESSED"

  * "UF_TRACKED"

  * "UF_DATAVAULT"

  * "UF_HIDDEN"

  * "SF_SETTABLE"

  * "SF_SUPPORTED"

  * "SF_SYNTHETIC"

  * "SF_ARCHIVED"

  * "SF_IMMUTABLE"

  * "SF_APPEND"

  * "SF_RESTRICTED"

  * "SF_NOUNLINK"

  * "SF_SNAPSHOT"

  * "SF_FIRMLINK"

  * "SF_DATALESS"

  * "FILE_ATTRIBUTE_ARCHIVE"

  * "FILE_ATTRIBUTE_COMPRESSED"

  * "FILE_ATTRIBUTE_DEVICE"

  * "FILE_ATTRIBUTE_DIRECTORY"

  * "FILE_ATTRIBUTE_ENCRYPTED"

  * "FILE_ATTRIBUTE_HIDDEN"

  * "FILE_ATTRIBUTE_INTEGRITY_STREAM"

  * "FILE_ATTRIBUTE_NORMAL"

  * "FILE_ATTRIBUTE_NOT_CONTENT_INDEXED"

  * "FILE_ATTRIBUTE_NO_SCRUB_DATA"

  * "FILE_ATTRIBUTE_OFFLINE"

  * "FILE_ATTRIBUTE_READONLY"

  * "FILE_ATTRIBUTE_REPARSE_POINT"

  * "FILE_ATTRIBUTE_SPARSE_FILE"

  * "FILE_ATTRIBUTE_SYSTEM"

  * "FILE_ATTRIBUTE_TEMPORARY"

  * "FILE_ATTRIBUTE_VIRTUAL"

  * "IO_REPARSE_TAG_SYMLINK"

  * "IO_REPARSE_TAG_MOUNT_POINT"

  * "IO_REPARSE_TAG_APPEXECLINK"

* "filecmp" — File and Directory Comparisons

  * "cmp()"

  * "cmpfiles()"

  * "clear_cache()"

  * The "dircmp" class

    * "dircmp"

      * "report()"

      * "report_partial_closure()"

      * "report_full_closure()"

      * "left"

      * "right"

      * "left_list"

      * "right_list"

      * "common"

      * "left_only"

      * "right_only"

      * "common_dirs"

      * "common_files"

      * "common_funny"

      * "same_files"

      * "diff_files"

      * "funny_files"

      * "subdirs"

    * "DEFAULT_IGNORES"

* "tempfile" — Generate temporary files and directories

  * "TemporaryFile()"

  * "NamedTemporaryFile()"

  * "SpooledTemporaryFile"

    * "rollover()"

  * "TemporaryDirectory"

    * "name"

    * "cleanup()"

  * "mkstemp()"

  * "mkdtemp()"

  * "gettempdir()"

  * "gettempdirb()"

  * "gettempprefix()"

  * "gettempprefixb()"

  * "tempdir"

  * Examples

  * Deprecated functions and variables

    * "mktemp()"

* "glob" — Unix style pathname pattern expansion

  * "glob()"

  * "iglob()"

  * "escape()"

  * "translate()"

  * Examples

* "fnmatch" — Unix filename pattern matching

  * "fnmatch()"

  * "fnmatchcase()"

  * "filter()"

  * "translate()"

* "linecache" — Random access to text lines

  * "getline()"

  * "clearcache()"

  * "checkcache()"

  * "lazycache()"

* "shutil" — High-level file operations

  * Directory and files operations

    * "copyfileobj()"

    * "copyfile()"

    * "SameFileError"

    * "copymode()"

    * "copystat()"

    * "copy()"

    * "copy2()"

    * "ignore_patterns()"

    * "copytree()"

    * "rmtree()"

      * "avoids_symlink_attacks"

    * "move()"

    * "disk_usage()"

    * "chown()"

    * "which()"

    * "Error"

    * Platform-dependent efficient copy operations

    * copytree example

    * rmtree example

  * Archiving operations

    * "make_archive()"

    * "get_archive_formats()"

    * "register_archive_format()"

    * "unregister_archive_format()"

    * "unpack_archive()"

    * "register_unpack_format()"

    * "unregister_unpack_format()"

    * "get_unpack_formats()"

    * Archiving example

    * Archiving example with *base_dir*

  * Querying the size of the output terminal

    * "get_terminal_size()"

See also:

  Module "os"
     Operating system interfaces, including functions to work with
     files at a lower level than Python *file objects*.

  Module "io"
     Python’s built-in I/O library, including both abstract classes
     and some concrete classes such as file I/O.

  Built-in function "open()"
     The standard way to open files for reading and writing with
     Python.
