[Python-ideas] argparse - add support for environment variables (a proposal)
Miki Tebeka
miki.tebeka at gmail.com
Wed Mar 27 18:15:35 CET 2013
IMO one env which is a ChainMap (
http://docs.python.org/dev/library/collections#collections.ChainMap) will
be enough.
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
> that
> each of them accepted a dictionary of options in a common form, so that
> they
> could be composed easily.
>
> For example, suppose we call config file parser 1st, and it returns a dict
> of
> what items are
> set in the config file (not the defaults). Then argparse is called
> (without
> using and defaults), passing it that dictionary, which it can add to or
> overide.
> Finally, options not in the dict get defaults applied.
>
> Having not dug into technical details, I'm imagining that either arparse
> already
> 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
> arparse.
>
> _______________________________________________
> Python-ideas mailing list
> Python... at python.org <javascript:>
> http://mail.python.org/mailman/listinfo/python-ideas
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-ideas/attachments/20130327/3bf91bad/attachment.html>
More information about the Python-ideas
mailing list