Mercurial > hg > configuration
changeset 141:c6aea14a3e2b
wip
author | Jeff Hammel <k0scist@gmail.com> |
---|---|
date | Mon, 01 Dec 2014 18:05:50 -0800 |
parents | 372315b3bb8e |
children | efd2d3330296 |
files | example/argparse_undefined.py |
diffstat | 1 files changed, 10 insertions(+), 1 deletions(-) [+] |
line wrap: on
line diff
--- a/example/argparse_undefined.py Thu Nov 06 07:41:05 2014 -0800 +++ b/example/argparse_undefined.py Mon Dec 01 18:05:50 2014 -0800 @@ -7,7 +7,16 @@ import argparse import sys -class UndefinedArgumentParser(argparse.ArgumentParser) +class Undefined(object): + """singleton""" + +Undefined = Undefined() + +class UndefinedArgumentParser(argparse.ArgumentParser): + + def add_argument(self, *args, **kwargs): + kwargs.setdefault('default', Undefined) + return argparse.ArgumentParser.add_argument def main(args=sys.argv[1:]):