argparse - specify order of argument parsing?

Eduardo Alvarez !nospam!astrochelonian at gmail.com
Sat Aug 31 13:11:38 EDT 2013


When using argparse, is there a way to specify in what order arguments
get parsed? I am writing a script whose parameters can be modified in
the following order:

Defaults -> config file -> command-line switches.

However, I want to give the option of specifying a config file using a
command line switch as well, so logically, that file should be parsed
before any other arguments are applied. However, it seems that
parse_args() parses arguments in the order they're given, so if the
config file switch is not given first, the config file will overwrite
whatever was in the command-line switches, which should have higher
priority.

Thank you in advance,
-- 
Eduardo Alvarez



More information about the Python-list mailing list