Skip to content

Latest commit

 

History

History
39 lines (34 loc) · 1.23 KB

README.md

File metadata and controls

39 lines (34 loc) · 1.23 KB

PyPI PyPI - Format License PyPI - Downloads GitHub last commit GitHub wheel size in bytes GitHub top language

Using this tool

This tool's format is very similar to that of the argparse module. Example setup:

import kwargparse

_kwarg_parser = kwargparse.KeywordArgumentParser()
def _init_kwarg_parser():
    _kwarg_parser.add_argument('hello')
    subp = _kwarg_parser.add_subparser('sub', default={'world': 20})
    subp.add_argument('world', default=20)

def main(**kwargs):
    result = _kwarg_parser.parse_kwargs(kwargs)
    print(result)
    print(result.sub.world)

_init_kwarg_parser()

if __name__ == '__main__':
    main(
        hello = 1,
        sub = dict(
            world = 2,
        ),
    )

Installing

To install simply use:

$ pip3 install kwargparse