def Date ( value ) : from datetime import datetime try : return datetime ( * reversed ( [ int ( val ) for val in value . split ( '/' ) ] ) ) except Exception as err : raise argparse . ArgumentTypeError ( "invalid date '%s'" % value )
python optionparser type date
Custom type for managing dates in the command - line .
def Date(value):
    """Custom type for managing dates in the command-line."""
    from datetime import datetime
    try:
        return datetime(*reversed([int(val) for val in value.split('/')]))
    except Exception as err:
        raise argparse.ArgumentTypeError("invalid date '%s'" % value)