[Python-3000] Combined configparse + optparse (interest?)

Fred Drake fdrake at acm.org
Wed Dec 12 06:52:49 CET 2007


On Dec 10, 2007, at 8:09 PM, Neal Becker wrote:
> Can python learn from c++?  Maybe sometimes.  I think the design of
> boost::program_options is a pretty example.

Nice, overall, but the devil is in the details, as always.  I didn't  
see anything in the documentation about how unrecognized values are  
handled; do they cause exceptions to be raised, or otherwise get  
reported to the application in some way?

Is the configuration file handled by that an ini file?  After looking  
around the documentation briefly, but without downloading the code/ 
tests, I couldn't see anything about the actual file format.  It's  
entirely possible I missed something; a link would be appreciated.

On the whole, while ignoring the C++-centric aspects of the API  
described in the documentation, I'm inclined to say that the model may  
be a lot simpler than would be needed for something like zc.buildout  
which ends up adding a lot on top of the basic ConfigParser model.   
But the boost::program_options package looks like it supports a much  
simpler model than ConfigParser.

ConfigParser provides only two parts of the boost::program_options  
"stack": a parser, and storage.  (Admittedly it conflates the two  
concerns.)  This is actually an advantage, as it supports alternate  
approaches to defining the schema for the configuration data.

The relationship between the command-line and configuration files can  
certainly be made easier to deal with by adding a schema component,  
but it's not actually necessary.  For zc.buildout, command line  
options of the form section:option=value are interpreted as another  
configuration file that takes precedence over the ini-format files  
that are loaded using ConfigParser.


   -Fred

-- 
Fred Drake   <fdrake at acm.org>



More information about the Python-3000 mailing list