[Python-ideas] argparse - add support for environment variables (a proposal)
miki.tebeka at gmail.com
Wed Mar 27 18:15:35 CET 2013
IMO one env which is a ChainMap (
This will give you more flexibility and you'll be able to chain more
"environments" if needed.
On Wednesday, March 27, 2013 8:47:45 AM UTC-7, Neal Becker wrote:
> Here's an idea. We have 4 main sources of config:
> 1. app defaults
> 2. config file
> 3. env var
> 4. command line
> Instead of adding anything to the code for each of these parsers, suppose
> each of them accepted a dictionary of options in a common form, so that
> could be composed easily.
> For example, suppose we call config file parser 1st, and it returns a dict
> what items are
> set in the config file (not the defaults). Then argparse is called
> using and defaults), passing it that dictionary, which it can add to or
> Finally, options not in the dict get defaults applied.
> Having not dug into technical details, I'm imagining that either arparse
> can accept a dict or options, or could be easily modified to. Or, we
> simply call
> argparse normally, then take it's dict and we merge the dicts outside of
> Python-ideas mailing list
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the Python-ideas