Return to Snippet

Revision: 41283
at February 15, 2011 11:37 by mouseroot


Initial Code
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]

Initial URL

                                

Initial Description
this stores the key=value pairs in a dictionary called cvars
perfect for config files
as always comments/critisim welcomed!

Initial Title
Read and Parse key=value; config file

Initial Tags

                                

Initial Language
Python