From 7fefaffcc2d6879c412496d523496a220b0440f5 Mon Sep 17 00:00:00 2001 From: Raymond Hettinger Date: Sun, 5 Sep 2010 23:50:32 +0000 Subject: [PATCH] Clean-up example of using fileinput as a context manager. --- Doc/library/fileinput.rst | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/Doc/library/fileinput.rst b/Doc/library/fileinput.rst index eac324d3183..7055f32ab0c 100644 --- a/Doc/library/fileinput.rst +++ b/Doc/library/fileinput.rst @@ -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.