summaryrefslogtreecommitdiff
path: root/Lib/pydoc.py
diff options
context:
space:
mode:
authorGiampaolo Rodola' <g.rodola@gmail.com>2013-02-12 02:04:27 +0100
committerGiampaolo Rodola' <g.rodola@gmail.com>2013-02-12 02:04:27 +0100
commit47726759cd9ea0324c8c035a970b3a2aa36fe763 (patch)
tree30c031dc58519a7d6f2ef80860714e158bb9685b /Lib/pydoc.py
parent02a0158ba7173ed0156a901add5b8f6a4ae497af (diff)
downloadcpython-47726759cd9ea0324c8c035a970b3a2aa36fe763.tar.gz
modernize some modules' code by using with statement around open()
Diffstat (limited to 'Lib/pydoc.py')
-rwxr-xr-xLib/pydoc.py5
1 files changed, 2 insertions, 3 deletions
diff --git a/Lib/pydoc.py b/Lib/pydoc.py
index 5a5a4813a8..292aa46015 100755
--- a/Lib/pydoc.py
+++ b/Lib/pydoc.py
@@ -1426,9 +1426,8 @@ def tempfilepager(text, cmd):
"""Page through text by invoking a program on a temporary file."""
import tempfile
filename = tempfile.mktemp()
- file = open(filename, 'w')
- file.write(text)
- file.close()
+ with open(filename, 'w') as file:
+ file.write(text)
try:
os.system(cmd + ' "' + filename + '"')
finally: