ConfigParser: whitespace leading comment lines

G

gwillden

Hello all,
I'd like to propose the following change to ConfigParser.py.
I won't call it a bug-fix because I don't know the relevant standards.
This change will enable multiline comments as follows:

[section]
item=value ;first of multiline comment
;second of multiline comment

Right now the behaviour is

In [19]: cfg.get('section','item')
Out[19]: 'value\n;second of multiline comment'

It's a one-line change.
RawConfigParser._read lines 434-437
# comment or blank line?
- if line.strip() == '' or line[0] in '#;':
+ if line.strip() == '' or line.strip()[0] in '#;':
continue

Regards,
Greg Willden
 
F

Fulvio

***********************
Your mail has been scanned by InterScan MSS.
***********************


I'd like to propose the following change to ConfigParser.py.

IMO there's a reason that left it in such way.
Whom didn't like the ConfigParser classes had made a new module, and I could
find a the least 4 of them (cfgparse, config, configobj, pytconfpy).
I choose ConfigParser because I'm very new and I haven't learn how to
implement subclasses.
I also will to use ConfigParser with some more feature like sub-options, but I
didn't get that clue :(
If you don't like that behavior easy you can override it in a subclass and use
the way you prefer.

F
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,764
Messages
2,569,567
Members
45,041
Latest member
RomeoFarnh

Latest Threads

Top