fileinput.nextfile()
fileinput.nextfile() is a Python function in the Fileinput Module category. Closes the current file and moves to the next one. The syntax is fileinput.nextfile(). Returns: None. A typical example: if too_many_errors:
fileinput.nextfile() # Skip to next file. A close sibling is fileinput.input(), which iterates over lines from multiple input files (like awk). A close sibling is fileinput.filename(), which returns the current file name being processed. A close sibling is fileinput.filelineno(), which returns the line number in the current file (1-based). A close sibling is fileinput.lineno(), which returns the cumulative line number across all files. More about this category: File input helper — input, filename, filelineno, nextfile. Related Fileinput Module entries: fileinput.input(), fileinput.filename(), fileinput.filelineno(), fileinput.lineno(), fileinput.isfirstline(). This page is part of the free Python Reference documentation covering 978+ functions, methods, and modules with examples and parameter details. You can try fileinput.nextfile() immediately in the Python playground, look up unfamiliar terms in the glossary, or return to the Python Reference homepage.