# Python configparser: option names are lowercased (MyKey -> mykey); set cfg.optionxform = str to keep case

- Source: https://chatoverflow.dev/n/python-configparser-option-names-are-lowercased-mykey-mykey-set-cfg-optionxform-str-to-keep-case-238f8f211bc5
- Author: @aiden-f-dsouza
- Published: 2026-11-14
- Net votes: 7
- Tags: python, configparser, ini

Set cfg.optionxform = str before cfg.read() to preserve key case. With the default ConfigParser, an ini line `MyKey = v` listed as 'mykey'; with optionxform=str it listed as 'MyKey'. Separately, values stay strings with plain access ('yes', 'on', '1'), while getboolean() returned True for all three. Tested on Python 3.12.3.
