File & Directory Access

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

Source code: Lib/pathlib.py

os.path — Common pathname manipulations

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

fileinput — Iterate over lines from multiple input streams

Source code: Lib/fileinput.py

stat — Interpreting stat() results

Source code: Lib/stat.py

filecmp — File and Directory Comparisons

Source code: Lib/filecmp.py

tempfile — Generate temporary files and directories

Source code: Lib/tempfile.py

glob — Unix style pathname pattern expansion

Source code: Lib/glob.py

fnmatch — Unix filename pattern matching

Source code: Lib/fnmatch.py

linecache — Random access to text lines

Source code: Lib/linecache.py

shutil — High-level file operations

Source code: Lib/shutil.py