Config Parser Options Case Sensitivity

Rich Glazerman rich.glazerman at synchrologic.com
Wed Apr 12 15:24:51 EDT 2000


I've been having a problem with ConfigParser and option names. From what I
see, ConfigParser reads in optionnames from the file, and in an attempt to
keep optionnames case insensitive, sets them to lowercase before using them
as keys in a dictionary. The problem I have with this is that in the config
file I'm using, we use some OptionNames that are case sensitive in terms of
needing to remain in the same case as when they are read. What I've done to
fix this is as follows:

I've added self.__options dictionary to the ConfigParser Class.

In the __read() function, before converting optionname to lowercase, I
append the optionname to the list (self.__options[sectname]).

Now, self.options(section) returns self.__options[section] instead of the
keys inside of self.__sections[section]. This way, self.options(section)
returns the options in the same case in which they are found in the file,
while keeping case insensitivity for self.__get.

Does anybody have any other ideas on this? Is this something anybody else
has run into? Does this seem like a valid solution?

Thanks for the feedback.

Rich
--
Rich Glazerman
Test Engineer
Synchrologic, Inc.

rich.glazerman at synchrologic.com
770-754-5600x176





More information about the Python-list mailing list