mirror of
https://github.com/python/cpython.git
synced 2025-08-27 04:05:34 +00:00
Use a context manager for some file objects.
This commit is contained in:
parent
24e561ae04
commit
7dde792e62
4 changed files with 20 additions and 32 deletions
|
@ -169,9 +169,8 @@ _CFG = {"width" : 0.5, # Screen
|
|||
|
||||
def config_dict(filename):
|
||||
"""Convert content of config-file into dictionary."""
|
||||
f = open(filename, "r")
|
||||
cfglines = f.readlines()
|
||||
f.close()
|
||||
with open(filename, "r") as f:
|
||||
cfglines = f.readlines()
|
||||
cfgdict = {}
|
||||
for line in cfglines:
|
||||
line = line.strip()
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue