/ Published in: Python
this stores the key=value pairs in a dictionary called cvars perfect for config files as always comments/critisim welcomed!
Expand |
Embed | Plain Text
cvars = {} def loadConfig(file): configfile = open(file,'r') configlist = configfile.readlines() for x in configlist: if x[:1] == '[' or x[:1] == '/': pass else: vars = x.replace(';','').split('=') cvars[vars[0]] = vars[1]
You need to login to post a comment.
