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:
- app defaults
- config file
- env var
- 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.