Q: argparse.add_argument()
Gisle Vanem
gvanem at yahoo.no
Sat Mar 18 14:02:55 EDT 2023
I accidentally used 'argparse' like this in my Python 3.9 program:
parser.add_argument ("-c, --clean", dest="clean", action="store_true")
parser.add_argument ("-n, --dryrun", dest="dryrun", action="store_true")
instead of:
parser.add_argument ("-c", "--clean", dest="clean", action="store_true")
parser.add_argument ("-n", "--dryrun", dest="dryrun", action="store_true")
So any use of 'my-prog.py -cn' threw an error:
error: unrecognized arguments: -cn
So is there something that throws an error on this wrong use of
"-c, --clean" instead? Could be useful. Or is "-c, --clean" legit somehow?
--
--gv
More information about the Python-list
mailing list