A package designed to simplify configurable defaults from argparse.
Project description
cfg_argparser 1.1.5
a config wrapper I made to be easily applied to argparse objects.
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.0.tar.gz
(7.6 kB
view hashes)
Built Distribution
Close
Hashes for cfg_argparser-1.2.0-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 1eeaa9768b8191b8cffcfe3f08d242a8df1f878fc9f7ef8aa808a6f9386bc456 |
|
MD5 | fc18ca2f31cf8312a00febe3fa997caa |
|
BLAKE2b-256 | 461f3c99da17e97d1ec60f0a87387b6659427d36d0dd85ea049b6ee554361bbf |