summaryrefslogtreecommitdiffstats
path: root/Doc/library/difflib.rst
diff options
context:
space:
mode:
authorÉric Araujo <merwok@netwok.org>2011-03-11 16:42:48 (GMT)
committerÉric Araujo <merwok@netwok.org>2011-03-11 16:42:48 (GMT)
commita3dd56b6cffaeee21fec6529b212fd4fa98c1ea8 (patch)
tree6b9fe78b2e36d78d159216950039a033ba9311a8 /Doc/library/difflib.rst
parent17b880a5d6b64f1e7d26ec8229e8b41cdf740690 (diff)
downloadcpython-a3dd56b6cffaeee21fec6529b212fd4fa98c1ea8.zip
cpython-a3dd56b6cffaeee21fec6529b212fd4fa98c1ea8.tar.gz
cpython-a3dd56b6cffaeee21fec6529b212fd4fa98c1ea8.tar.bz2
Use with statement where it improves the documentation (closes #10461)
Diffstat (limited to 'Doc/library/difflib.rst')
-rw-r--r--Doc/library/difflib.rst4
1 files changed, 2 insertions, 2 deletions
diff --git a/Doc/library/difflib.rst b/Doc/library/difflib.rst
index a0afe81..505d308 100644
--- a/Doc/library/difflib.rst
+++ b/Doc/library/difflib.rst
@@ -750,8 +750,8 @@ It is also contained in the Python source distribution, as
# 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,