diff options
author | Giampaolo Rodola' <g.rodola@gmail.com> | 2013-02-12 01:04:27 (GMT) |
---|---|---|
committer | Giampaolo Rodola' <g.rodola@gmail.com> | 2013-02-12 01:04:27 (GMT) |
commit | 2f50aaf2ff427fb713e82699a6dcbeeb038b10c2 (patch) | |
tree | 0e2c24897b8918f19d8504915ccebd466c0bbd92 /Lib/pydoc.py | |
parent | fd6e6cfa29b2289e711dc7f57f36897c78899ee7 (diff) | |
download | cpython-2f50aaf2ff427fb713e82699a6dcbeeb038b10c2.zip cpython-2f50aaf2ff427fb713e82699a6dcbeeb038b10c2.tar.gz cpython-2f50aaf2ff427fb713e82699a6dcbeeb038b10c2.tar.bz2 |
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 5a5a481..292aa46 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: |