I have a python script that requires some command line inputs and I am using argparse for parsing them. I found the documentation a bit confusing and couldn\'t find a way to
Just to add on to the answer above, you can use a lambda function if you want to keep it to a one-liner. For example:
parser.add_argument('--date', type=lambda d: datetime.strptime(d, '%Y%m%d'))
Old thread but the question was still relevant for me at least!