[issue21805] Argparse Revert config_file defaults

paul j3 report at bugs.python.org
Fri Jun 20 18:59:27 CEST 2014


paul j3 added the comment:

Another approach would be make the 'argparse' argument a 'switch' command, and act on it after parsing.  Roughly what I have in mind is:

    parser.add_argument('--verbosity', dest='switch_verbosity, action='store_true', help='....'%config_defaults['verbose'])
    ....
    args = parser.parse_args()

    verbosity = config_defaults['verbose']
    if args.switch_verbosity:
       verbosity = not verbosity

In other words, you don't need to do all of the manipulation of values in 'argparse' itself.  Its primary purpose is to decipher what the user wants, and secondarily to guide him (with help, error messages, etc).

----------
nosy: +paul.j3

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue21805>
_______________________________________


More information about the Python-bugs-list mailing list