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 exited, even if an exception occurs:
with fileinput.input(files=('spam.txt', 'eggs.txt')) as f: for line in f: process(line)
Changed in version 3.2: Can be used as a context manager.
Changed in version 3.5.2: The bufsize parameter is no longer used.
Please login to continue.