8000 gh-66449: configparser: Add support for unnamed sections by pslacerda · Pull Request #117273 · python/cpython · GitHub
[go: up one dir, main page]

Skip to content

gh-66449: configparser: Add support for unnamed sections #117273

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 11 commits into from
Mar 29, 2024
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Better documentation
  • Loading branch information
pslacerda committed Mar 29, 2024
commit 80d566bbe627ad6ae035a100521cd480f2b1946b
7 changes: 4 additions & 3 deletions Doc/library/configparser.rst
99A6
Original file line number Diff line number Diff line change
Expand Up @@ -331,6 +331,7 @@ For example:

Unnamed sections
----------------

THe name of the first section (or unique) can be ommitted and values
retrieved by the :attr:`UNNAMED_SECTION` attribute.

Expand All @@ -342,9 +343,9 @@ retrieved by the :attr:`UNNAMED_SECTION` attribute.
... [ Section 2 ]
... another = val
... """
>>> typical = configparser.ConfigParser(allow_unamed_section=True)
>>> typical.read_string(config)
>>> config.get(UNNAMED_SECTION, 'option')
>>> unnamed = configparser.ConfigParser(allow_unamed_section=True)
>>> unnamed.read_string(config)
>>> unnamed.get(UNNAMED_SECTION, 'option')
'value'

Interpolation of values
Expand Down
0