# Package for config and argument handling?

**URL:** <https://discuss.python.org/t/package-for-config-and-argument-handling/17375>\
**Category:** Python Help\
**Created:** [July 15, 2022, 10:38am UTC](https://discuss.python.org/t/package-for-config-and-argument-handling/17375 "2022-07-15T10:38:08Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![kpfleming](https://sea2.discourse-cdn.com/flex002/user_avatar/discuss.python.org/kpfleming/32/2761_2.png) [@kpfleming](https://discuss.python.org/u/kpfleming)\
**Post date:** [July 15, 2022, 10:38am UTC](https://discuss.python.org/t/package-for-config-and-argument-handling/17375/1 "2022-07-15T10:38:08Z")

</div>

I need to build a new tool, and it needs to handle command line arguments (for which I’ll use argparse) and have a configuration file.

Anyone have recommendations for packages that combine these two things so that configurable options can be supplied either way?

---

<div class="post-metadata">

**Author:** ![abravalheri](https://sea2.discourse-cdn.com/flex002/user_avatar/discuss.python.org/abravalheri/32/4990_2.png) [@abravalheri](https://discuss.python.org/u/abravalheri)\
**Post date:** [July 15, 2022, 3:16pm UTC](https://discuss.python.org/t/package-for-config-and-argument-handling/17375/2 "2022-07-15T15:16:01Z")

</div>

They might be not the most elegant solutions but I did hack something before using all of the following methods:

1. [argparse’s buitin fromfile\_prefix\_chars](https://docs.python.org/3/library/argparse.html?highlight=argparse#fromfile-prefix-chars).
2. [click’s Context.default\_map](https://click.palletsprojects.com/en/8.1.x/api/#context) - [see also complex application](https://click.palletsprojects.com/en/8.1.x/complex/?highlight=configuration%20file)
3. The “overkill” [OmegaConf](https://omegaconf.readthedocs.io/en/2.1_branch/) - when using this one I always tend to use [dataclasses to add some structure/validation](https://omegaconf.readthedocs.io/en/2.1_branch/structured_config.html).

---

<div class="post-metadata">

**Author:** ![kpfleming](https://sea2.discourse-cdn.com/flex002/user_avatar/discuss.python.org/kpfleming/32/2761_2.png) [@kpfleming](https://discuss.python.org/u/kpfleming)\
**Post date:** [July 15, 2022, 6:28pm UTC](https://discuss.python.org/t/package-for-config-and-argument-handling/17375/3 "2022-07-15T18:28:09Z")

</div>

Thanks! I’m going to experiment with `ConfigArgParse`, as it’s lightweight and the eventual deployment target for this code is relatively small systems (like OpenWrt devices).
