[Python-bugs-list] [ python-Bugs-592527 ] comments taken as values in ConfigParser

noreply@sourceforge.net noreply@sourceforge.net
Sat, 17 Aug 2002 09:41:47 -0700


Bugs item #592527, was opened at 2002-08-08 05:11
You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=592527&group_id=5470

Category: Python Library
Group: 3rd Party
Status: Open
Resolution: None
Priority: 5
Submitted By: Artūras Kriukovas (drugelis)
Assigned to: Raymond Hettinger (rhettinger)
Summary: comments taken as values in ConfigParser

Initial Comment:
Let's say we have config file config.conf with contents:


[forms]
....
myParameter = myValue # my comment here :) 
# and my comment here
....

[other sections]
.......


We run python code:

    import sys, os
    from ConfigParser import *
    fileLocations = ['......./config.conf']
    parser = ConfigParser()
    parser.read(fileLocations)
    parser.sections()

and when we run:
    parser.get('forms', 'manoParameter')

we get:
    'myValue # my comment here :)'

The comment is also included as key value. The second
comment is left out as it should be.
The simpliest way to fix it probaby would be remove all
string after the first '#' char (that is to leave
string part to first '#' char).

----------------------------------------------------------------------

Comment By: Jonathan Simms (slyphon)
Date: 2002-08-17 11:41

Message:
Logged In: YES 
user_id=404786

Hello, 

In the documentation for the ConfigParser module, it 
says

"Lines *beginning* with "#" or ";" are ignored and may 
be used to provide comments. "

After reviewing the source for ConfigParser.py, as far 
as I can tell, the parser does NOT support end-of-line 
comments in config files.

Hope this helps, 
Jonathan

----------------------------------------------------------------------

You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=592527&group_id=5470