diff Doc/library/difflib.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 3c9232a684ae
children aff9bcbd2fc7
line wrap: on
line diff
--- a/Doc/library/difflib.rst	Fri Mar 11 17:27:02 2011 +0100
+++ b/Doc/library/difflib.rst	Fri Mar 11 17:42:48 2011 +0100
@@ -750,8 +750,8 @@
        # we're passing these as arguments to the diff function
        fromdate = time.ctime(os.stat(fromfile).st_mtime)
        todate = time.ctime(os.stat(tofile).st_mtime)
-       fromlines = open(fromfile, 'U').readlines()
-       tolines = open(tofile, 'U').readlines()
+       with open(fromlines) as fromf, open(tofile) as tof:
+           fromlines, tolines = list(fromf), list(tof)
 
        if options.u:
            diff = difflib.unified_diff(fromlines, tolines, fromfile, tofile,