Skip to main content

confng-py

A simple configuration management tool for python. You can use it to manage your python application's configuration in a simple and flexible way.

Install

pip install confng-py

Usage

from confng import Conf

# create a new Conf instance with a config object and MergeEnvOptions
# If you don't want to merge environment variables, you can omit the merge_env_options option.
# The value of `config` is JSON. You can parse it from json/toml/yaml/... file, or directly pass an object.
# The logic should be implemented in your own code.
conf = Conf(
    ConfOptions(
        config={
            "name": "foo",
            "server": {
                "port": 3000,
                "host": "localhost",
            },
            "logs": [
                {
                    "level": "info",
                    "output": "console",
                },
            ],
            "nums": [1, 2, 3],
        },
        merge_env_options=MergeEnvOptions(prefix="FOO", separator="__"),
    )
)

print(conf.get('name')); # foo
print(conf.get('server.port')); # 3000
print(conf.get('server.host')); # localhost

# The inner of Conf will guess the type of the value automatically from the initial config object.
# So the inital config object should be in full form, and the value of each key should be in the correct type.

# if the following environment variables setted 
# FOO__SERVER__PORT=4000 
# FOO__SERVER__HOST=example.com
print(conf.get('server.port')); # here will return 4000 and the data type is number.
print(conf.get('server.host')); # example.com

Load config from file

import os
import json

from confng import Conf

# read config from conifg/default.json
config_path = os.path.join('config', 'default.json')
with open(config_path, 'r') as f:
    config = json.load(f)

conf = Conf(ConfOptions(config=config))

print(conf.get('name'));

Thanks

This package is inspired by the following packages:

Metadata

Release files for confng-py 0.2.2

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

Source distribution (sdist)

Source distribution for confng-py 0.2.2
File Size Uploaded
confng_py-0.2.2.tar.gz 17.5 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for confng-py 0.2.2
File Interpreter ABI Platform
confng_py-0.2.2-py3-none-any.whl Python 3 none any Details

Total release size: 23.2 kB

Release files / confng_py-0.2.2.tar.gz

Download URL confng_py-0.2.2.tar.gz
Size 17.5 kB
Tags Source
SHA-256 checksum
How to use checksums
de6b956a9ff1d75b6e755e57ca6c6a59b2c1cd55686d3ae3c582ba70cc6cca0c
BLAKE2b-256 checksum
How to use checksums
381bfdbe27224fad0300c096e228c237ad195168a4a6cca74733c05ea8b25fc7
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.7

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 Sep 11, 2025.

Transparency log

Release files / confng_py-0.2.2-py3-none-any.whl

Download URL confng_py-0.2.2-py3-none-any.whl
Size 5.7 kB
Tags Python 3
SHA-256 checksum
How to use checksums
08073a3a19d7e5960cda8ec225c8c05c0803e01827f4606df2df3fb56f8b43d0
BLAKE2b-256 checksum
How to use checksums
4794ebf64ac465a3265f82d88026005b869f22135f6eacd1778be6cff0c9e7b0
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.7

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 Sep 11, 2025.

Transparency log

Release history Release notifications | RSS feed

This release

0.2.2 This release

2 release files

0.2.1

2 release files

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