I have a python script that requires input of several commands and I use argparse to parse them. I found the documentation a bit confusing and could not find a way to check the format in the input parameters. What I mean by format validation is explained using this sample script:
parser.add_argument('-s', "--startdate", help="The Start Date - format YYYY-MM-DD ", required=True) parser.add_argument('-e', "--enddate", help="The End Date format YYYY-MM-DD (Inclusive)", required=True) parser.add_argument('-a', "--accountid", type=int, help='Account ID for the account for which data is required (Default: 570)') parser.add_argument('-o', "--outputpath", help='Directory where output needs to be stored (Default: ' + os.path.dirname(os.path.abspath(__file__)))
I need to check for the -s and -e options that the user input is in the format YYYY-MM-DD . Is there an option in argparse that I don't know about what this does.
Sohaib Aug 24 '14 at 10:41 2014-08-24 10:41
source share