This is definitely a "nice thing to potentially have" instead of an issue but something that might make more "pythonic" sense is to have config be a class defined like this:
class Config():
def __init__(self, config_file):
self.config = {}
with open(config_file) as file_:
for line in file_:
line = line.strip()
if line and line[0] is not "#":
var,value = line.split('=', 1)
self.config[var.strip()] = value.strip()
def __getitem__(self, key):
# Potential error-checking code if key not in self.config
return self.config[key]
Then you can just do config = Config(config_file) and call config["attr"] to get the value of attr in config. This sounds like a pretty useless change but Mike and I had spent a bit of time thinking about how to do a config file in python so I feel like it would be good to have. Let me know if you have any suggestions!
This is definitely a "nice thing to potentially have" instead of an issue but something that might make more "pythonic" sense is to have config be a class defined like this:
Then you can just do config = Config(config_file) and call config["attr"] to get the value of attr in config. This sounds like a pretty useless change but Mike and I had spent a bit of time thinking about how to do a config file in python so I feel like it would be good to have. Let me know if you have any suggestions!