Argument Parsers¶
Overview¶
Python is script executor, so when to adjust the scripts witout changing code, we can config at the argument parser. This align with environment variables to make change of the script in the runtime.
Basic Usages¶
The official document¶
The boolean components¶
If you want to
Python 3.9+:
Python < 3.9:
parser.add_argument('--feature', action='store_true')
parser.add_argument('--no-feature', dest='feature', action='store_false')
parser.set_defaults(feature=True)
Ref: from 1
The tool can support with https://kislyuk.github.io/argcomplete/
This tool help working is more easier
And it align with
Reference¶
-
[Parsing boolean values with argparse]https://stackoverflow.com/questions/15008758/parsing-boolean-values-with-argparse ↩