diff options
author | Raymond Hettinger <python@rcn.com> | 2010-09-05 23:50:32 (GMT) |
---|---|---|
committer | Raymond Hettinger <python@rcn.com> | 2010-09-05 23:50:32 (GMT) |
commit | 7fefaffcc2d6879c412496d523496a220b0440f5 (patch) | |
tree | 6347e94a691107a2873e1e4b0ed2279139ce647e /Doc | |
parent | d5825ccd404a61a08fd3211a41eb30baa27e2dfd (diff) | |
download | cpython-7fefaffcc2d6879c412496d523496a220b0440f5.zip cpython-7fefaffcc2d6879c412496d523496a220b0440f5.tar.gz cpython-7fefaffcc2d6879c412496d523496a220b0440f5.tar.bz2 |
Clean-up example of using fileinput as a context manager.
Diffstat (limited to 'Doc')
-rw-r--r-- | Doc/library/fileinput.rst | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/Doc/library/fileinput.rst b/Doc/library/fileinput.rst index eac324d..7055f32 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. |