Here are two functions that show how to use ConfigParser.

py>def ConfigWrite(key, value, section, cfgpath):
...      import ConfigParser, pprint
...      parser=ConfigParser.ConfigParser()
...      cfg = open(cfgpath,'w')
...      parser.add_section(section)
...      Pretty = pprint.PrettyPrinter()#optional
...      value = Pretty.pformat(value)#optional
...      parser.set(section,key,value)
...      parser.write(cfg)
...      cfg.close()


py>def ConfigReader(key, section, cfgpath):
...      import ConfigParser
...      parser=ConfigParser.ConfigParser()
...      parser.read(cfgpath)
...      return parser.get(section,key)
Hope that helps...now *where* are  those sugar cookies 
M.E.Farmer

-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to