File & Directory Access Articles

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:

filecmp — File and Directory Comparisons

Source code: Lib/filecmp.py

fileinput — Iterate over lines from multiple input streams

Source code: Lib/fileinput.py

fnmatch — Unix filename pattern matching

Source code: Lib/fnmatch.py

glob — Unix style pathname pattern expansion

Source code: Lib/glob.py

linecache — Random access to text lines

Source code: Lib/linecache.py

os.path — Common pathname manipulations

Source code: Lib/posixpath.py (for POSIX) and Lib/ntpath.py (for Windows NT).

pathlib — Object-oriented filesystem paths

Source code: Lib/pathlib.py

shutil — High-level file operations

Source code: Lib/shutil.py

stat — Interpreting stat() results

Source code: Lib/stat.py

tempfile — Generate temporary files and directories

Source code: Lib/tempfile.py