diff Doc/tutorial/stdlib2.rst @ 68376:c3d28c84a372

Use with statement where it improves the documentation (closes #10461)
author Éric Araujo <merwok@netwok.org>
date Fri, 11 Mar 2011 17:42:48 +0100
parents 203945060baf
children 62ddf16eea24
line wrap: on
line diff
--- a/Doc/tutorial/stdlib2.rst	Fri Mar 11 17:27:02 2011 +0100
+++ b/Doc/tutorial/stdlib2.rst	Fri Mar 11 17:42:48 2011 +0100
@@ -141,7 +141,9 @@
 
    import struct
 
-   data = open('myfile.zip', 'rb').read()
+   with open('myfile.zip', 'rb') as f:
+       data = f.read()
+
    start = 0
    for i in range(3):                      # show the first 3 file headers
        start += 14