Skip to main content

Python >=3.11 PyPI - Version Python tests

Code style: black Nox

commented-configparser

A custom ConfigParser class that preserves comments and most formatting when writing loaded config out.

This library gives you a custom class of the standard library's configparser.ConfigParger which will preserve the comments of a loaded config file when writing that file back out.


Install via pip

From pypi:

python -m pip install commented-configparser

From github:

python -m pip install commented-configparser@git+https://github.com/Preocts/commented-configparser@x.x.x

Note: Replace x.x.x with the desired tag or branch.


Example use

from commentedconfigparser import CommentedConfigParser

# Load the config like normal
config = CommentedConfigParser()
config.read("myconfig.ini")

# Use the config like normal
...

# Update the config like normal
...

# Save the config back to the file
with open("myconfig.ini", "w") as savefile:
    config.write(savefile)

Results

There is the attempt to retain the original format. Known formats that will not be preserved:

  1. Indents will not be preserved outside of multi-line values
  2. Spacing around assignments will be normalized.

Before

# Welcome to our config
[DEFAULT]
# This value has some meaning to someone
foo=bar
# Make sure to add this when you need it
trace=false
logging=true
; This is a comment as well

    # so we need to track all of them

	; and many could be between things
[NEW SECTION]
# Another comment
multiLine=
	value01
	value02
	value03
closing=0
# Trailing comment

After

# Welcome to our config
[DEFAULT]
# This value has some meaning to someone
foo = bar
# Make sure to add this when you need it
trace = false
logging = true
; This is a comment as well

# so we need to track all of them

; and many could be between things
[NEW SECTION]
# Another comment
multiLine =
	value01
	value02
	value03
closing = 0
# Trailing comment

Metadata

Release files for commented-configparser 3.1.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for commented-configparser 3.1.1
File Size Uploaded Provenance
commented_configparser-3.1.1.tar.gz 57.1 kB With provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for commented-configparser 3.1.1
File Interpreter ABI Platform
commented_configparser-3.1.1-py3-none-any.whl Python 3 none any Details

Total release size: 62.6 kB

Release files / commented_configparser-3.1.1.tar.gz

Download URL commented_configparser-3.1.1.tar.gz
Size 57.1 kB
Tags Source
SHA-256 checksum
How to use checksums
d356e35ca17998f4d294e9c3a9711769418f5db9b1cfca59ae875b3511e627d5
BLAKE2b-256 checksum
How to use checksums
a8b548696607730b0d4845c7da16c64d361fccecf95bcb8b5812af02c19f0164
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 25, 2026.

Transparency log

Release files / commented_configparser-3.1.1-py3-none-any.whl

Download URL commented_configparser-3.1.1-py3-none-any.whl
Size 5.5 kB
Tags Python 3
SHA-256 checksum
How to use checksums
2997c659657ed843d5be860af0a4771001977d57bf66fd056a10b335a7a59aeb
BLAKE2b-256 checksum
How to use checksums
3d9a8d7ec699398a2fde17220b979332f916cb2b450aa6e491fdcc1b6a1666df
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 25, 2026.

Transparency log

Security for commented-configparser 3.1.1

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

Full provenance

All 2 files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for commented_configparser-3.1.1.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 25, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page