[Python-Dev] Extension to ConfigParser (original) (raw)
Tony Meyer t-meyer at ihug.co.nz
Tue Jan 31 20:54:42 CET 2006
- Previous message: [Python-Dev] Extension to ConfigParser
- Next message: [Python-Dev] Extension to ConfigParser
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
[Paul Moore]
* No way to merge files or sections. Usually to provide default values. I have a suite of applications, all using the same framework. I have a hardcoded DEFAULTCONFIG in the code, overriden by a .ini, overridden again by a .ini. OK, maybe it's overengineered, but I do use the various levels, so it's also useful... (The defaults parameter to the constructor is misnamed, AFAICT, as it's for interpolation defaults, not value defaults).
Why doesn't this work? It does here:
$ cat suite.ini [sect] opt1 = 1 opt2 = 2 $ cat app.ini [sect] opt1 = 3 opt4 = 5 $ python Python 2.4.1 (#2, Mar 31 2005, 00:05:10) [GCC 3.3 20030304 (Apple Computer, Inc. build 1666)] on darwin Type "help", "copyright", "credits" or "license" for more information.
import ConfigParser c = ConfigParser.ConfigParser() c.read(("suite.ini", "app.ini")) ['suite.ini', 'app.ini'] c.sections() ['sect'] c.options("sect") ['opt4', 'opt2', 'opt1'] c.get("sect", "opt1") '3'
Or do you mean something else?
=Tony.Meyer
- Previous message: [Python-Dev] Extension to ConfigParser
- Next message: [Python-Dev] Extension to ConfigParser
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]