/ Published in: Python
this stores the key=value pairs in a dictionary called cvars
perfect for config files
as always comments/critisim welcomed!
perfect for config files
as always comments/critisim welcomed!
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
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]