Home     My Faqts     Contributors     About     Help    

faqts : Computers : Programming : Languages : Python

FAQTs repaired & updated!
Thanks for your patience...
Entry Add Entry Alert - Edit this Entry

Did You Find This Entry Useful?

19 of 22 people (86%) answered Yes
Recently 8 of 10 people (80%) answered Yes

Why ConfigParser--does not preserve case in ConfigParser.options['mysection']

May 28th, 2001 17:29

Christopher Arndt, Mamoon Khan

Dunno _why_ it behaves like this (maybe because windows, where this
kind of configuration file is common, is a non-case-distinguishing
system) but I it's in the source code, _how_ this is done:
Look into <pythonlibdir>/ConfigParser.py.
The culprit is in line 310 (Python 1.5.2) resp. line 468 (Python 2.1) in
method _read().
Also affected is the method get() and maybe others too.
In the version that comes with Python 2.1 you can change this behaviour
on the fly:
>>> import ConfigParser
>>> p = ConfigParser.ConfigParser()
>>> p.optionxform = lambda x: x
>>> p.read('win.ini')
>>> p.options('Windows Hilfe')
['H_WindowPosition', 'M_WindowPosition', 'C_WindowPosition']

© 1999-2004 Synop Pty Ltd