Use a context manager for some file objects.

This commit is contained in:
Florent Xicluna 2010-09-03 19:52:03 +00:00
parent 24e561ae04
commit 7dde792e62
4 changed files with 20 additions and 32 deletions

View file

@ -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()