|
From: Bob S. <Bob...@ou...> - 2017-02-28 15:35:48
|
I have searched extensively and not found anything that answers the following:
In creating a config file with nested Sections, how can I later in the file return to defining items (i.e., key/value pairs) at the top-level section?
E.g., if in the following file:
# --------------- start thisFile.ini
top1 = 100
top2 = 200
[LEVEL1]
Level1A = 1000
[LEVEL2]
Level2A = 2000
# Now I want top3 to be defined in the top level, rather than in Section [LEVEL1][LEVEL2]
top3 = 200
# ---------------- end thisFile.ini
When the config file is processed, cfg=ConfigObj('thisFile.ini'), I'd like top3 to be cfg['top3'], instead of as cfg['LEVEL1']['LEVEL2']['top3']. My only guess was to change the last 2 lines to:
[] # hoping maybe return to top level ?
top3 = 200
... but that does not work and causes an exception. So as best I can determine it seems that all top-level definitions must precede any use of a Section.
Is that actually correct, or is there a way to return to defining items at the top level?
Thanks in advance for any help or advice.
|