Replies: 5 comments
-
|
parser.set_default might be a good shout, automatically enabling overrides from command line args. |
Beta Was this translation helpful? Give feedback.
-
|
Can you given an example? |
Beta Was this translation helpful? Give feedback.
-
thing: 42
unrelated.key: valuedefaults = load_name('name')
parser = ArgumentParser()
parser.add_argument('-t', '--thing', type=int, help='value for the thing')
parser.set_defaults(**defaults)
arguments = parser.parse_args()
main(arguments.thing)
Rationale behind the issue was two somewhat common use cases, as configuration and command line arguments often go hand in hand:
|
Beta Was this translation helpful? Give feedback.
-
|
Ok so, the argsparse 'makes' a configuration object that has highest precedence? |
Beta Was this translation helpful? Give feedback.
-
|
Sort of, I'd think. I don't think confidence should extend argparse or take control over these things for these kinds of use cases. Come to think of it, this type of integration should maybe just get documented decently, giving users the hints on what is going to work and what might bite them. I was planning to get a head start on some decent docs in the coming weeks, so this might need to become a section somewhere. |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Maybe target builtin argument parsers (argparse, optparse seems to be have been deprecated) first, making sure to not bite the likes of docopt / click. Also important:
NAME_CONFIG_FILEenvvars?--config path/to/conf.yaml?Configuration.include(namespace_object)or include 'something' in the load order?Beta Was this translation helpful? Give feedback.
All reactions