[Python-checkins] r84546 - python/branches/py3k/Doc/library/fileinput.rst

raymond.hettinger python-checkins at python.org
Mon Sep 6 01:50:32 CEST 2010


Author: raymond.hettinger
Date: Mon Sep  6 01:50:32 2010
New Revision: 84546

Log:
Clean-up example of using fileinput as a context manager.

Modified:
   python/branches/py3k/Doc/library/fileinput.rst

Modified: python/branches/py3k/Doc/library/fileinput.rst
==============================================================================
--- python/branches/py3k/Doc/library/fileinput.rst	(original)
+++ python/branches/py3k/Doc/library/fileinput.rst	Mon Sep  6 01:50:32 2010
@@ -58,8 +58,9 @@
    :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.


More information about the Python-checkins mailing list