Friday, 30 August 2013

argparse: How to add optional or once arguments

argparse: How to add optional or once arguments

How can I add an argument that is optional and must not be specified
multiple times?
Valid:
./my.py
./my.py -arg 123
Invalid:
./my.py -arg 123 -arg 234
If I add an argument like:
parser.add_argument('-arg', type=str)
The invalid example results in a value of "234". I would expect an parser
error.

No comments:

Post a Comment