]> granicus.if.org Git - python/commitdiff
Clean-up example of using fileinput as a context manager.
authorRaymond Hettinger <python@rcn.com>
Sun, 5 Sep 2010 23:50:32 +0000 (23:50 +0000)
committerRaymond Hettinger <python@rcn.com>
Sun, 5 Sep 2010 23:50:32 +0000 (23:50 +0000)
Doc/library/fileinput.rst

index eac324d31838819f79c9537736a761f4bb5c7e3e..7055f32ab0c8a91761e6822fc1f04361b2e3bda0 100644 (file)
@@ -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.