A package designed to simplify configurable defaults from argparse.
Project description
cfg_argparser 1.2.1
a config wrapper I made.
Installation
# from pypi:
pip install cfg-argparser
# from github:
git clone "https://github.com/zeptofine/cfg-argparser"
cd cfg-argparser
pip install -e .
Example
from cfg_argparser import wrap_config, CfgDict
cfg = CfgDict("test.json")
@wrap_config(cfg)
def test_function(s: str, is_real: bool = True): # I'd advise only wrapping functions all having default methods
return f"{s} is {'real' if is_real else 'fake'}"
if __name__ == "__main__":
print(test_function("We"))
cfg['s'] = "us"
print(test_function()) # Linters hate him!
Compatibilty
This was mainly tested on 3.9 and 3.10, but it should work from 3.6 onwards. i can't test earlier versions for some reason.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
cfg-argparser-1.2.1.tar.gz
(7.8 kB
view hashes)
Built Distribution
Close
Hashes for cfg_argparser-1.2.1-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 35bf51ae269ebb106098d566543028fa1814cdabaeaa7f403510a48efe9d29c1 |
|
MD5 | b394f8c767f34283af3b577952f79faa |
|
BLAKE2b-256 | c250692e7c1b4dc9170e9e726ff331e9ee219227a44fb86b00c7d4cec46cd4f1 |