Skip to main content

Minimalistic Python library for your configs.

Project description

Minimalistic Python library for your configs.

How to?

At first, install libary:

pip install betterconf

And... write simple config:

from betterconf import field, Config

class MyConfig(Config):
    my_var = field("my_var")

cfg = MyConfig()
print(cfg.my_var)

Try to run:

my_var=1 python our_file.py

With default values:

from betterconf import field, Config

class MyConfig(Config):
    my_var = field("my_var", default="hello world")

cfg = MyConfig()
print(cfg.my_var)
# hello world

Override values when it's needed (for an example: test cases)

from betterconf import field, Config

class MyConfig(Config):
    my_var = field("my_var", default="hello world")

cfg = MyConfig(my_var="WOW!")
print(cfg.my_var)
# WOW!

By default betterconf gets all values from os.environ but sometimes we need much. You can create own field value provider in minutes:

from betterconf import field, Config
from betterconf.config import AbstractProvider

class NameProvider(AbstractProvider):
    def get(self, name: str):
        return name

class Cfg(Config):
    my_var = field("my_var", provider=NameProvider())

cfg = Cfg()
print(cfg.my_var)
# my_var

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

betterconf-1.5.tar.gz (3.3 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

betterconf-1.5-py3-none-any.whl (3.5 kB view details)

Uploaded Python 3

File details

Details for the file betterconf-1.5.tar.gz.

File metadata

  • Download URL: betterconf-1.5.tar.gz
  • Upload date:
  • Size: 3.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.0.0 CPython/3.7.5 Linux/5.0.0-37-generic

File hashes

Hashes for betterconf-1.5.tar.gz
Algorithm Hash digest
SHA256 ffd9d7b9e46d9d621f086667b99669ba4b442b69cd2916b8c202989d579b04bc
MD5 7d29e32b4d991e8429b589e1999f6442
BLAKE2b-256 90e9438939c447ad798ee08af3912ccd7f2148440c66c0948ce690be0382c22b

See more details on using hashes here.

File details

Details for the file betterconf-1.5-py3-none-any.whl.

File metadata

  • Download URL: betterconf-1.5-py3-none-any.whl
  • Upload date:
  • Size: 3.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.0.0 CPython/3.7.5 Linux/5.0.0-37-generic

File hashes

Hashes for betterconf-1.5-py3-none-any.whl
Algorithm Hash digest
SHA256 fa72c19116767e517e74db521db74b78b7e84a6af3f126e812bb867418370269
MD5 1333263738ac8023d400a8a0a0d46bd2
BLAKE2b-256 539b0a77a2f163e9fb224fe240fdadff893b947feb7bcb36ad6975e200e6a615

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page