You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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:
classConfig():
def__init__(self, config_file):
self.config= {}
withopen(config_file) asfile_:
forlineinfile_:
line=line.strip()
iflineandline[0] isnot"#":
var,value=line.split('=', 1)
self.config[var.strip()] =value.strip()
def__getitem__(self, key):
# Potential error-checking code if key not in self.configreturnself.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!
The text was updated successfully, but these errors were encountered:
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!
The text was updated successfully, but these errors were encountered: