comparison example/argparse_undefined.py @ 144:df5350aee9c3

not sure what i did here
author Jeff Hammel <k0scist@gmail.com>
date Thu, 11 Dec 2014 18:07:10 -0800
parents 2825b0fdf80e
children
comparison
equal deleted inserted replaced
143:2825b0fdf80e 144:df5350aee9c3
14 14
15 class UndefinedArgumentParser(argparse.ArgumentParser): 15 class UndefinedArgumentParser(argparse.ArgumentParser):
16 16
17 def __init__(self, *args, **kwargs): 17 def __init__(self, *args, **kwargs):
18 argparse.ArgumentParser.__init__(self, *args, **kwargs) 18 argparse.ArgumentParser.__init__(self, *args, **kwargs)
19 self.__defaults = {}
19 20
20 def add_argument(self, *args, **kwargs): 21 def add_argument(self, *args, **kwargs):
21 kwargs.setdefault('default', Undefined) 22 default = kwargs.pop('default', self.argument_default)
22 return argparse.ArgumentParser.add_argument 23 return argparse.ArgumentParser.add_argument
23 24
24 def main(args=sys.argv[1:]): 25 def main(args=sys.argv[1:]):
25 26
26 parser = UndefinedArgumentParser() 27 parser = UndefinedArgumentParser()