Comments in ConfigParser module
Gabriel Genellina
gagsl-py2 at yahoo.com.ar
Mon Apr 9 18:42:29 EDT 2007
En Sun, 08 Apr 2007 06:17:46 -0300, Joel Granados
<joel.granados at gmail.com> escribió:
> On 7 Apr 2007 13:19:06 -0700, Gabriel Genellina <gagsl-py2 at yahoo.com.ar>
> wrote:
>>
>> Joel Andres Granados wrote:
>>
>> > The module also allows the comments to appear in the same line as the
>> > "name = value" constructs. The only difference being that this is
>> only
>> > possible with ";" and not with "#" character. I did not see this in
>> the
>> > documentation but this is how it is behaving.
>>
>> Yes, it's not documented. There is only a comment in the source code:
>>
>> # ';' is a comment delimiter only if it
>> follows
>> # a spacing character
>>
>> I think it's either a bug in the code or in the documentation.
>
> Yep, IMO its a weirdness in the behavior that is not documented.
It was a bit hard, but I finally found the original Windows ini-file
specification at <http://www.microsoft.com/technet/archive/wfw/2_ch6.mspx>
where you can see ; used as comment delimiter.
ConfigParser tries to handle both RFC822-like headers (with name: value,
including continuation lines, but ignoring almost everything else in the
syntax) and ini files (with ; as comments), plus some unique features like
# comments and "rem" lines removal (?). That is, it tries to cover a lot
of formats without a clear specification.
Add wrong defaults usage, and the need for SafeConfigParser, and some
other gotchas... then switch to use alternative implementations like
ConfigObj <http://www.voidspace.org.uk/python/configobj.html>
--
Gabriel Genellina
More information about the Python-list
mailing list