mirror of
https://github.com/AdaCore/cpython.git
synced 2026-02-12 12:57:15 -08:00
Clean-up example of using fileinput as a context manager.
This commit is contained in:
@@ -58,8 +58,9 @@ The following function is the primary interface of this module:
|
||||
:keyword:`with` statement. In this example, *input* is closed after the
|
||||
:keyword:`with` statement is exited, even if an exception occurs::
|
||||
|
||||
with fileinput.input(files=('spam.txt', 'eggs.txt')) as input:
|
||||
process(input)
|
||||
with fileinput.input(files=('spam.txt', 'eggs.txt')) as f:
|
||||
for line in f:
|
||||
process(line)
|
||||
|
||||
.. versionchanged:: 3.2
|
||||
Can be used as a context manager.
|
||||
|
||||
Reference in New Issue
Block a user