[issue11027] Allow spaces around section header in ConfigParser

2011-01-27 Thread Kunjesh Kaushik
New submission from Kunjesh Kaushik kunjesh.kaus...@gmail.com: It is often desirable to be able to write a section with spaces around the header, as in [ default ] instead of [default] for the sake of readability of configuration file. I am not sure if this is the standard format of

[issue11027] Allow spaces around section header in ConfigParser

2011-01-27 Thread R. David Murray
R. David Murray rdmur...@bitdance.com added the comment: A feature request can only go in to 3.3 at this point. ConfigParser has had a serious overhaul in 3.2, by the way. -- assignee: - lukasz.langa nosy: +lukasz.langa, r.david.murray versions: +Python 3.3 -Python 2.7

[issue11027] Allow spaces around section header in ConfigParser

2011-01-27 Thread Raymond Hettinger
Raymond Hettinger rhettin...@users.sourceforge.net added the comment: There's a case to be made that the current regex is buggy. It already accepts whitespace around the header name but doesn't strip it. ISTM, this is undesirable: [ section header ] -- ' section header ' instead of

[issue11027] Allow spaces around section header in ConfigParser

2011-01-27 Thread Kunjesh Kaushik
Kunjesh Kaushik kunjesh.kaus...@gmail.com added the comment: Mr. Raymond has raised a valid point. On second thought, I think the submitted patch won't resolve the issue. import re r = re.compile(r'\[\s*(?Pheader[^]]+)\s*\]') # as in the patch r.match('[ section header ]').group('header')

[issue11027] Allow spaces around section header in ConfigParser

2011-01-27 Thread R. David Murray
R. David Murray rdmur...@bitdance.com added the comment: Well, there's still a backward compatibility issue: if this is changed, currently working code may break. Maybe Lukasz or Fred will have a guess as to how likely that is, because I don't. -- nosy: +fdrake

[issue11027] Allow spaces around section header in ConfigParser

2011-01-27 Thread Fred L. Drake, Jr.
Fred L. Drake, Jr. fdr...@acm.org added the comment: I doubt anyone is looking for section names with leading or trailing whitespace. One approach to dealing with this is to provide and sectionxform similar to optionxform. If we're wrong and someone really is expecting leading or trailing

[issue11027] Allow spaces around section header in ConfigParser

2011-01-27 Thread Raymond Hettinger
Raymond Hettinger rhettin...@users.sourceforge.net added the comment: Could just expand the docs to show examples of customizing behavior through monkey-patching or subclassing: class MyConfigParser(ConfigParser): SECTRE = re.compile(r'[\*(?Pheader[^]]+)\s*]' or:

[issue11027] Allow spaces around section header in ConfigParser

2011-01-27 Thread Kunjesh Kaushik
Kunjesh Kaushik kunjesh.kaus...@gmail.com added the comment: I think we are dealing with two separate issues: a feature request for sectionxform kind of functionality desirable in a future release (3.3 maybe) and a behaviour issue in current releases (2.x and 3.x both). I suggest we split the