why does Configparser change names to lowercase ?

S

stef mientki

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
 
J

James Stroud

stef said:
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
 
R

Rob Wolfe

stef mientki said:
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
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,055
Latest member
SlimSparkKetoACVReview

Latest Threads

Top