Name
input
Synopsis
input(files=None,inplace=0,backup='',bufsize=0)
Returns the sequence of lines in the files, suitable for use in a
for loop. files is a
sequence of filenames to open and read one after the other, in order.
Filename '-' means standard input
(sys.stdin). If files
is a string, it’s a single filename to open and
read. If files is None,
input uses sys.argv[1:] as the
list of filenames If the sequence of filenames is empty,
input reads sys.stdin.
The sequence object that input returns is an
instance of class FileInput; that instance is also
the global state of module input, so all other
functions of module fileinput operate on the same
shared state. Each function of module fileinput
corresponds directly to a method of class
FileInput.
When inplace is false (the default),
input just reads the files. When
inplace is true, however,
input moves each file being read (except standard
input) to a backup file, and redirects standard output
(sys.stdout) to write to the file being read. This
operation lets you simulate overwriting files in-place. If
backup is a string starting with a dot,
input uses backup as
the extension of the backup files and does not remove the backup
files. If backup is an empty string (the
default), input uses extension
.bak, and deletes each backup file when the file
is closed.
bufsize is the size of the internal buffer
that input uses to read lines from the input
files. If bufsize is 0,
input uses a buffer of 8192 bytes.