[stdlib-sig] ConfigParser - parsing options with no value

Mats Kindahl mats at sun.com
Sun Sep 27 08:19:13 CEST 2009



R. David Murray wrote:
> On Thu, 17 Sep 2009 at 22:28, Mats Kindahl wrote:
>> Where should I post such patches and what is people opinion of these to
>> alternatives?
> 
> The bug tracker (bugs.python.org).
> 
>> Another consideration is how to allow this extension. It would be
>> possible to
>> add flags to allow new and old behaviour, but I don't know how much
>> value people
>> attribute to be able to get an exception if there is no value for the
>> option.
> 
> Python's philosophy is to remain backward compatible, so this new
> behavior should be controlled by an option of some sort whose default
> value is the old behavior.

OK. This suggestion for improvement is now registered as Issue 7005. It contain
changes to ConfigParser.py as well as an extended test case. I elected to add a
parameter allow_no_value to __init__ and use the default False. Also, options
without values are registered with the value None, so that they can be
distinguished from options that have the empty string as value.

> 
>> I am also thinking that some option files have extensions to be able
>> to include
>> files (MySQL option parsing package has), so it might be a good idea
>> to add
>> callbacks to handle unrecognized lines, allowing the callback to
>> inject text
>> into the parsing stream to, for example, support include files or even
>> a macro
>> language.
> 
> That should be a separate feature request/tracker issue/patch.

It's on my todo list.

Best wishes,
Mats Kindahl

> 
> --David

-- 
Mats Kindahl
Senior Software Engineer
Database Technology Group
Sun Microsystems


More information about the stdlib-sig mailing list