Content-Length: 291137 | pFad | https://github.com/python/cpython/issues/136282

69 configparser: create unnamed section with mapping protocol access · Issue #136282 · python/cpython · GitHub
Skip to content

configparser: create unnamed section with mapping protocol access #136282

@Rogdham

Description

@Rogdham

Feature or enhancement

Current state (3.14):

Since gh-123077 (CPython 3.14), it is possible to create an unnamed section with configparser:

>>> cfg1 = configparser.ConfigParser(allow_unnamed_section=True)
>>> cfg1.add_section(configparser.UNNAMED_SECTION)
>>> cfg1.set(configparser.UNNAMED_SECTION, "foo", "bar")
>>> cfg1.write(fobj1)

This gives the following output file:

foo = bar

However, the mapping protocol access is not supported:

>>> cfg2 = configparser.ConfigParser(allow_unnamed_section=True)
>>> cfg2[configparser.UNNAMED_SECTION] = {"foo": "bar"}
>>> cfg2.write(fobj2)

Gives the following output file:

[<UNNAMED_SECTION>]
foo = bar


Proposal:

Implement the mapping protocol for access of the unnamed section in configparser.

Has this already been discussed elsewhere?

This is a minor feature, which does not need previous discussion elsewhere

Links to previous discussion of this feature:

No response

Linked PRs

Metadata

Metadata

Assignees

No one assigned

    Labels

    stdlibStandard Library Python modules in the Lib/ directorytype-featureA feature request or enhancement

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions









      ApplySandwichStrip

      pFad - (p)hone/(F)rame/(a)nonymizer/(d)eclutterfier!      Saves Data!


      --- a PPN by Garber Painting Akron. With Image Size Reduction included!

      Fetched URL: https://github.com/python/cpython/issues/136282

      Alternative Proxies:

      Alternative Proxy

      pFad Proxy

      pFad v3 Proxy

      pFad v4 Proxy