9.10. Related Modules

There are plenty of other modules related to files and input/output, all of which work on most of the major platforms. Table9.7 lists some of the file-related modules.

Table 9.7. Related File Modules
Module(s)Contents
fileinputiterates over lines of multiple input text files
getoptprovides command-line argument parsing/manipulation
glob/fnmatchprovides Unix-style wildcard character matching
gzip/zlib/zipfile[a]allows file access to include automatic de/compression
shutiloffers high-level file access functionality
c/StringIOimplements file-like interface on top of string objects
tempfilegenerates temporary file names or files

[a] new in Python 1.6

The fileinput module iterates over a set of input files and reads their contents one ...

Get Core Python Programming now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.