mirror of
https://github.com/python/cpython.git
synced 2025-08-24 10:45:53 +00:00
modernize some modules' code by using with statement around open()
This commit is contained in:
parent
fd6e6cfa29
commit
2f50aaf2ff
14 changed files with 50 additions and 89 deletions
|
@ -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:
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue