ConfigParser: buggy or just a mess?

David Goodger goodger at python.org
Fri Oct 24 16:58:11 EDT 2003


Martin Maney wrote:
 > Summary: with batteries like these, get a longer extension cord?
 >
 > [most of this was written before I came across the brief explanation
 > on the wiki, which did more to explain ConfigParser than everything
 > in the official documentation, while inspiring the executive summary
 > above.]

If you can write it better, doc patches are welcome!

 > <transcript from interactive session>
 > Python 2.2.1 (#1, Sep  7 2002, 14:34:30)

Before complaining, check the latest version to see if the bug has
already been fixed:

     Python 2.3 (#2, Jul 30 2003, 11:45:28)
     [GCC 3.1 20020420 (prerelease)] on darwin
     Type "help", "copyright", "credits" or "license" for more information.
     >>> from ConfigParser import ConfigParser
     >>> cp = ConfigParser()
     >>> cp.readfp(open('conf'))
     >>> cp.options('test')
     ['a', 'b']
     >>> cp.has_option('test', 'a')
     True
     >>> cp.has_option('test', 'b')
     True

Here's my "conf" file (next time, please include your data too):

     [test]
     a = 1

     [DEFAULT]
     b = 2

-- 
David Goodger    http://starship.python.net/~goodger
For hire: http://starship.python.net/~goodger/cv
Docutils: http://docutils.sourceforge.net/
(includes reStructuredText: http://docutils.sf.net/rst.html)







More information about the Python-list mailing list