fileinput.lineno()

fileinput.lineno() Return the cumulative line number of the line that has just been read. Before the first line has been read, returns 0. After the last line of the last file has been read, returns the line number of that line.

fileinput.isfirstline()

fileinput.isfirstline() Returns true if the line just read is the first line of its file, otherwise returns false.

fileinput.input()

fileinput.input(files=None, inplace=False, backup='', bufsize=0, mode='r', openhook=None) Create an instance of the FileInput class. The instance will be used as global state for the functions of this module, and is also returned to use during iteration. The parameters to this function will be passed along to the constructor of the FileInput class. The FileInput instance can be used as a context manager in the with statement. In this example, input is closed after the with statement is exite

fileinput.isstdin()

fileinput.isstdin() Returns true if the last line was read from sys.stdin, otherwise returns false.

fileinput.hook_encoded()

fileinput.hook_encoded(encoding) Returns a hook which opens each file with open(), using the given encoding to read the file. Usage example: fi = fileinput.FileInput(openhook=fileinput.hook_encoded("iso-8859-1"))

FileNotFoundError

exception FileNotFoundError Raised when a file or directory is requested but doesn’t exist. Corresponds to errno ENOENT.

fileinput.filename()

fileinput.filename() Return the name of the file currently being read. Before the first line has been read, returns None.

fileinput.hook_compressed()

fileinput.hook_compressed(filename, mode) Transparently opens files compressed with gzip and bzip2 (recognized by the extensions '.gz' and '.bz2') using the gzip and bz2 modules. If the filename extension is not '.gz' or '.bz2', the file is opened normally (ie, using open() without any decompression). Usage example: fi = fileinput.FileInput(openhook=fileinput.hook_compressed)

fileinput.fileno()

fileinput.fileno() Return the integer “file descriptor” for the current file. When no file is opened (before the first line and between files), returns -1.

fileinput.close()

fileinput.close() Close the sequence.