February 2006
Intermediate to advanced
648 pages
14h 53m
English
The fileinput module iterates over a list of input files and reads their contents line by line. The main interface to the module is the following function:
input([files [, inplace [, backup]]])
Creates an instance of the FileInput class. files is an optional list of filenames to be read (a single filename is also permitted). If omitted, the filenames are read from the command line in sys.argv[1:]. An empty list implies input from stdin, as does a filename of '-'. If inplace is set to True, each input file is moved to a backup file and sys.stdout is redirected to overwrite the original input file. The backup file is then removed when the output is closed. The backup option specifies a filename extension such as .bak that is appended ...