ConfigParser shootout, preliminary entry

Skip Montanaro skip at pobox.com
Sat Oct 23 00:14:54 EDT 2004


    Michael> A few weeks ago, the suggestion was made on Python-Dev that it
    Michael> might be time to consider replacing the ConfigParser module and
    Michael> that we should hold a "shootout" (ie ask for implementations
    Michael> and see what we get).

I put up a parser on my Python bits page and referenced it from the Wiki
Shootout page:

    http://www.musi-cal.com/~skip/python/cfgparse.py
    http://www.python.org/moin/ConfigParserShootout

  Features (essentially the doc string):

    * File format is indentation-based (where'd he get that idea???)

    * Both attribute-style and dictionary-style access supported

    * File format is *not* compatible with Windows INI file
      - section introduced by line ending with colon (another brilliant
        coup!)
      - values are specified by simple key = value lines

    * Nesting to arbitrary depths is supported

    * Read and write with round trip, though comments are not currently
    preserved.

    * Proof-of-concept only - there's not much of an api yet - no
    sections(), has_section(), as_dict() methods, etc.  That should be easy
    enough to add later.

    * Typeless - everything's a string.  Python has plenty of ways to
    convert strings to other types of objects.

I wrote it more as an exercise and to satisfy myself that to deal with more
general config structures than Windows INI files supports you don't have to
fall into the XML tarpit.  I suspect it's not more featureful than Michael
Chermside's example implementation though it's somewhat shorter.

Skip



More information about the Python-list mailing list