Łukasz Langa <luk...@langa.pl> added the comment:

Kunjesh, first of all many thanks for your feedback! A bit of advice, though. I 
have myself made the mistake of calling features I personally want as "often 
needed". The reality is that they are not often needed if they weren't reported 
before. While the current behaviour is not intuitive and probably unwelcome, 
it's hardly a bug if it has been that way for 15 years now.

At one point I had `sectionxform` implemented for configparser 3.2 but it made 
the source less readable. Then I thought about what Raymond taught me: is this 
a feature that follows a real use case? I concluded it didn't so I left it out. 
That being said, your report proves that such functionality would be welcome. I 
checked and ConfigObj does strip whitespace from section names, too. 
Nevertheless, in my opinion that's a feature request that only applies to 
Python 3.3. Your patches are for 2.7.

Let me elaborate a bit on a broader issue: configparser as of 3.2 still has 
only limited ability to write configuration files back (it strips whitespace 
and comments between options, option names get xformed). I want to fix that for 
3.3 so the file can be altered and written back with only minimal changes. 
`optionxform` already gets in the way, `sectionxform` would too, if improperly 
implemented.

Raymond, I would want to keep the regexes as raw as possible as to enable 
writing the file back with the whitespace preserved. That includes whitespace 
around the section name, if we are to support that.

To conclude: I won't touch the regexes, I will implement `sectionxform` while 
implementing on-save whitespace and comment preservation for 3.3.

----------
keywords:  -patch
stage:  -> needs patch
title: Allow spaces around section header in ConfigParser -> Implement 
sectionxform in configparser

_______________________________________
Python tracker <rep...@bugs.python.org>
<http://bugs.python.org/issue11027>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to