Comments in ConfigParser module

Joel Andres Granados joel.granados at gmail.com
Fri Apr 6 07:12:23 EDT 2007


Hi list:

I have run across a situation with ConfigParser Module.   It refers to 
the comments in the configuration filed.  According to the 
http://docs.python.org/dev/lib/module-ConfigParser.html it states that 
lines starting with "#" and ";" are ignored. 
So lines like:
; comment
# comment
are considered comments.  So far so good.

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.
So while the following line takes the comment as a comment.
*name = value ; comment*
the next line does not result in the same behavior.
*name = value # comment*
the name element would have "value # comment" as its value, when what I 
really want is for "comment" to be taken as a comment.

QUESTION...So the question is:
Can you use "#" and ";" as comment characters? and if so why does the 
"#" not apply for the same situations as the ";"?  I'm working with fc7 
(I synced it sometime last week) and python 2.5 (r25:51908, Feb 13 2007, 
09:13:20)

Any comment greatly appreciated....


Just for reference:
On the RFC 822 <http://www.faqs.org/rfcs/rfc822.html> (a document 
referenced in the documentation) there is a mention of ";" being used as 
comment character but not necessarily at the beginning of the line. 
So anything that comes after the ";" is ignored.
name = value ; comment  (";comment" would be ignored)






More information about the Python-list mailing list