ConfigParser lower-cases options automatically?

M

Matthew Wilson

I'm using ConfigParser to store and retreive some data across multiple
runs of my program and it looks like it automatically lower-cases my
options:

---this is the program:

import ConfigParser
cp = ConfigParser.ConfigParser()
cp.add_section('info')
cp.set('info', 'Previous-IP', '0.0.0.0')
out = open('out.txt', 'w')
cp.write(out)
out.close()
out = open('out.txt')
print out.read()

---here is the data:

[info]
previous-ip = 0.0.0.0

---end


I wonder if this is something intentionally built-in to ConfigParser in
order to remove case-sensitivity issues that are variable across
platforms. Does anyone else have any comments or ideas? I don't need
case-sensitivity in my script, but I am puzzled by this behavior.
 
J

Jarek Zgoda

Matthew Wilson said:
I wonder if this is something intentionally built-in to ConfigParser in
order to remove case-sensitivity issues that are variable across
platforms. Does anyone else have any comments or ideas? I don't need
case-sensitivity in my script, but I am puzzled by this behavior.

Yes, I think it was intentional. Check optionxform() in Python
documentation to get an idea how to make ConfigParser case sensitive.
 

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,581
Members
45,056
Latest member
GlycogenSupporthealth

Latest Threads

Top