[Python-Dev] ConfigParser mangles keys with special chars

Fred Drake fred at fdrake.net
Fri Apr 25 21:58:26 CEST 2014


On Fri, Apr 25, 2014 at 3:12 PM, Ethan Furman <ethan at stoneleaf.us> wrote:
> Perhaps an enhancement request then:  a way to provide a regex that keys
> must match, with an exception raised when a key doesn't.  That way the
> safety belt could be used when desired.

You can subclass the parser class you're using and override the
``optionxform`` method to perform the checks you want for option
names.  I don't know if current versions provide a similar hook to
validate section names; providing *that* would be an excellent
enhancement.


  -Fred

-- 
Fred L. Drake, Jr.    <fred at fdrake.net>
"A storm broke loose in my mind."  --Albert Einstein


More information about the Python-Dev mailing list