class DictAction(argparse.Action):

    def __call__(self, parser, namespace, values, option_string=None):
        setattr(namespace, self.dest, self.choices.get(values, self.default))
value_dict = {'on': True, 'off': False, 'switch': None}
parser.add_argument('-v', '--value', action=DictAction, choices=value_dict,
    default=None)
Use dictionary for Python argparse