Skip to main content

INI Comments

This is a ini-file handler that preserves comments.

For various projects of mine, I prefer to provide comments within an ini file for others to know their meanings, or other options.

While configParser is nice, it always removed any/all comments from the file, so this project solves that issue.

Features:

  • Supports: "#", ";" and "//" as line comments
  • Preserve comments
  • Handles "line comment" and "comments behind values"
  • Custom "separator" (default: "=")
  • Allows toggle between: "instant save" or "on purpose"
  • May handle "lazy" (bStrict=False) ini files, that do not have any "[Section]"s (this is required for the saving, wether manual or automatic)
  • Allows for fallback/non-existing config

Usage:

How to handle this class:

Available commands:

  • my_ini.export(args)
  • my_ini.get(args)
  • my_ini.get_simple(args)
  • my_ini.list_sections()
  • my_ini.list_variables(args)
  • my_ini.load_data()
  • my_ini.load_file()
  • my_ini.save()
  • my_ini.set(args)
  • my_ini.set_simple(args)

Import:

import inicomments

Initialize:

my_ini = inicomments.handler("/path/to/file")

Working with values:

# Get value:
current_value = my_ini.get("SectionName", "VariableName")
print(current_value)

# Set Value:
my_ini.set("SectionName", "VariableName", "NewValue")

Special Handling:

If you have bInstantSave=False you simply call: my_ini.save() at whatever point you want/need to save the file.

Example File:

Here is an example of a - very chaotic, but still work-able - ini file:

# Most used comment
; But you can apply any comment style
// that fits your project

[section]
variable = some value
someting = with a comment // like this
ofCourse = this would ; work as well
sooooo = "would this ; if you" ; apply quotes

Metadata

Release files for inihelper 0.1.0

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

Source distribution (sdist)

Source distribution for inihelper 0.1.0
File Size Uploaded Provenance
inihelper-0.1.0.tar.gz 16.7 kB Without provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for inihelper 0.1.0
File Interpreter ABI Platform
inihelper-0.1.0-py3-none-any.whl Python 3 none any Details

Total release size: 34.1 kB

Release files / inihelper-0.1.0.tar.gz

Download URL inihelper-0.1.0.tar.gz
Size 16.7 kB
Tags Source
SHA-256 checksum
How to use checksums
e826c9ae69b38ff76360fe9eb4b89a33d81b958d06be235b977e26148a216e9a
BLAKE2b-256 checksum
How to use checksums
66f811f6f2c1d891f3914cac4ecb2c74f9f4c61f94ae0cab85e3a7f7651d5441
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.14.3

Release files / inihelper-0.1.0-py3-none-any.whl

Download URL inihelper-0.1.0-py3-none-any.whl
Size 17.4 kB
Tags Python 3
SHA-256 checksum
How to use checksums
013e39834e6b00ea8dd05a53ba86b60a2b4179a4c449240563bfa8f6a66ff262
BLAKE2b-256 checksum
How to use checksums
f14b46acb38f6650cacc67943df8a7e1b77b7b439ea4d25c42b84346b4755f3e
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.14.3

Security for inihelper 0.1.0

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.

No provenance found

None of the files in this release were uploaded with provenance metadata.

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.

Release history Release notifications | RSS feed

This release

0.1.0 This release

2 release files No provenance

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