Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 7fefaff

Browse files
committed
Clean-up example of using fileinput as a context manager.
1 parent d5825cc commit 7fefaff

1 file changed

Lines changed: 3 additions & 2 deletions

File tree

Doc/library/fileinput.rst

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,8 +58,9 @@ The following function is the primary interface of this module:
5858
:keyword:`with` statement. In this example, *input* is closed after the
5959
:keyword:`with` statement is exited, even if an exception occurs::
6060

61-
with fileinput.input(files=('spam.txt', 'eggs.txt')) as input:
62-
process(input)
61+
with fileinput.input(files=('spam.txt', 'eggs.txt')) as f:
62+
for line in f:
63+
process(line)
6364

6465
.. versionchanged:: 3.2
6566
Can be used as a context manager.

0 commit comments

Comments
 (0)