why does Configparser change names to lowercase ?

Discussion in 'Python' started by stef mientki, Sep 14, 2007.

  1. stef mientki

    stef mientki Guest

    hello,

    Why does Configparser change names to lowercase ?

    As Python is case sensitive (which btw I don't like at all ;-)
    but now when really need the casesensitivity,
    because it handles about names which should be recognized by human,
    it changes everything to lowercase ????

    thanks,
    Stef Mientki
    stef mientki, Sep 14, 2007
    #1
    1. Advertising

  2. stef mientki

    James Stroud Guest

    stef mientki wrote:
    > hello,
    >
    > Why does Configparser change names to lowercase ?


    Because it is an annoying module and should be tossed for something
    better? Try this instead (and never look back):

    http://www.voidspace.org.uk/python/configobj.html


    > As Python is case sensitive (which btw I don't like at all ;-)
    > but now when really need the casesensitivity,
    > because it handles about names which should be recognized by human,
    > it changes everything to lowercase ????


    So you are saying the case sensitivity is a good thing--or maybe you are
    still running Mac System 7 on your CSIIsi marveling at the wonders of HFS?

    James
    James Stroud, Sep 14, 2007
    #2
    1. Advertising

  3. stef mientki

    Rob Wolfe Guest

    stef mientki <> writes:

    > hello,
    >
    > Why does Configparser change names to lowercase ?
    >
    > As Python is case sensitive (which btw I don't like at all ;-)
    > but now when really need the casesensitivity,
    > because it handles about names which should be recognized by human,
    > it changes everything to lowercase ????


    I don't know why, but I know how to change it and I found the solution here:
    http://docs.python.org/lib/RawConfigParser-objects.html

    You need to change the implementation of method `optionxform`, e.g.:

    # config
    [section1]
    option1=item1
    Option2=item2
    option2=item3

    # cfg.py
    from ConfigParser import ConfigParser

    config = ConfigParser()
    config.optionxform = str
    config.read('config')
    print config.get('section1', 'option1')
    print config.get('section1', 'Option2')
    print config.options('section1')

    HTH,
    Rob
    Rob Wolfe, Sep 14, 2007
    #3
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Mr. SweatyFinger
    Replies:
    2
    Views:
    1,840
    Smokey Grindel
    Dec 2, 2006
  2. Glen
    Replies:
    2
    Views:
    248
  3. Guest
    Replies:
    0
    Views:
    742
    Guest
    Sep 18, 2007
  4. Replies:
    3
    Views:
    428
  5. dieter
    Replies:
    0
    Views:
    101
    dieter
    Feb 2, 2013
Loading...

Share This Page