[Baypiggies] ConfigParser

Ian Zimmerman itz at buug.org
Thu Nov 4 04:28:02 CET 2010


>>>>> "akleider" == akleider  <akleider at sonic.net> writes:

akleider> I've just discovered the the ConfigParser module converts it's
akleider> dictionary key:value pairs all into lower case.  Why?  Is
akleider> there a way to get the same functionality (another module
akleider> perhaps) that respects case?

Copied from the documentation:

class ConfigParser.ConfigParser([defaults[, dict_type]])

    Derived class of RawConfigParser that implements the magical
    interpolation feature and adds optional arguments to the get() and
    items() methods. The values in defaults must be appropriate for the
    %()s string interpolation. Note that __name__ is an intrinsic
    default; its value is the section name, and will override any value
    provided in defaults.

    All option names used in interpolation will be passed through the
    optionxform() method just like any other option name reference. For
    example, using the default implementation of optionxform() (which
    converts option names to lower case), the values foo %(bar)s and foo
    %(BAR)s are equivalent.


So, you need to override the optionxform method either by subclassing or
replacing it in the object instance.

By the way, don't use the Reply All/Followup feature of your mailer
unless that is what you're really doing.  Address books are your friends.

-- 
Ian Zimmerman <itz at buug.org>
gpg public key: 1024D/C6FF61AD 
fingerprint: 66DC D68F 5C1B 4D71 2EE5  BD03 8A00 786C C6FF 61AD
Ham is for reading, not for eating.


More information about the Baypiggies mailing list