Parsing Complex INI Files in Python with configparser - Unexpected Behavior on Section Defaults
I'm updating my dependencies and I'm attempting to set up I'm not sure how to approach I'm trying to parse a complex INI file using Python's built-in `configparser` library, but I've run into some unexpected behavior when dealing with section defaults... My INI file has multiple sections, and I want to set defaults for specific keys, but the parser seems to ignore them under certain conditions. Here's the structure of my INI file: ```ini [DEFAULT] key1 = default_value1 key2 = default_value2 [SectionA] key1 = overridden_value1 [SectionB] key2 = overridden_value2 ``` When I attempt to read these values, I use the following code: ```python import configparser config = configparser.ConfigParser() config.read('config.ini') value1_a = config.get('SectionA', 'key1') # Should return 'overridden_value1' value2_a = config.get('SectionA', 'key2') # Should return 'default_value2' value1_b = config.get('SectionB', 'key1') # Should return 'default_value1' value2_b = config.get('SectionB', 'key2') # Should return 'overridden_value2' ``` However, when I run this code, I get the following error for `value1_b`: ``` No option 'key1' in section: 'SectionB' ``` As per my understanding, since `key1` is defined in the `DEFAULT` section, I expect it to be available in `SectionB`, similar to how `key2` behaves. I've checked the official documentation, and it states that options from the `DEFAULT` section should be inherited by other sections, but it seems like I'm missing something. Am I using `configparser` incorrectly, or is there something specific about how defaults work that I'm overlooking? I'm currently using Python 3.9.1. Any help would be greatly appreciated! Hoping someone can shed some light on this. I'm working in a Windows 11 environment. I recently upgraded to Python latest. I appreciate any insights!