summaryrefslogtreecommitdiffstats
path: root/Doc/library/fileinput.rst
diff options
context:
space:
mode:
authorRaymond Hettinger <python@rcn.com>2010-09-05 23:50:32 (GMT)
committerRaymond Hettinger <python@rcn.com>2010-09-05 23:50:32 (GMT)
commit7fefaffcc2d6879c412496d523496a220b0440f5 (patch)
tree6347e94a691107a2873e1e4b0ed2279139ce647e /Doc/library/fileinput.rst
parentd5825ccd404a61a08fd3211a41eb30baa27e2dfd (diff)
downloadcpython-7fefaffcc2d6879c412496d523496a220b0440f5.zip
cpython-7fefaffcc2d6879c412496d523496a220b0440f5.tar.gz
cpython-7fefaffcc2d6879c412496d523496a220b0440f5.tar.bz2
Clean-up example of using fileinput as a context manager.
Diffstat (limited to 'Doc/library/fileinput.rst')
-rw-r--r--Doc/library/fileinput.rst5
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.