diff options
author | Giampaolo Rodola' <g.rodola@gmail.com> | 2013-02-12 02:04:27 +0100 |
---|---|---|
committer | Giampaolo Rodola' <g.rodola@gmail.com> | 2013-02-12 02:04:27 +0100 |
commit | 47726759cd9ea0324c8c035a970b3a2aa36fe763 (patch) | |
tree | 30c031dc58519a7d6f2ef80860714e158bb9685b /Lib/pydoc.py | |
parent | 02a0158ba7173ed0156a901add5b8f6a4ae497af (diff) | |
download | cpython-47726759cd9ea0324c8c035a970b3a2aa36fe763.tar.gz |
modernize some modules' code by using with statement around open()
Diffstat (limited to 'Lib/pydoc.py')
-rwxr-xr-x | Lib/pydoc.py | 5 |
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: |