diff options
Diffstat (limited to 'Doc/library/argparse.rst')
-rw-r--r-- | Doc/library/argparse.rst | 18 |
1 files changed, 9 insertions, 9 deletions
diff --git a/Doc/library/argparse.rst b/Doc/library/argparse.rst index 0bb57c1..6a7f8ef 100644 --- a/Doc/library/argparse.rst +++ b/Doc/library/argparse.rst @@ -35,10 +35,10 @@ produces either the sum or the max:: parser = argparse.ArgumentParser(description='Process some integers.') parser.add_argument('integers', metavar='N', type=int, nargs='+', - help='an integer for the accumulator') + help='an integer for the accumulator') parser.add_argument('--sum', dest='accumulate', action='store_const', - const=sum, default=max, - help='sum the integers (default: find the max)') + const=sum, default=max, + help='sum the integers (default: find the max)') args = parser.parse_args() print(args.accumulate(args.integers)) @@ -488,7 +488,7 @@ specified characters will be treated as files, and will be replaced by the arguments they contain. For example:: >>> with open('args.txt', 'w') as fp: - ... fp.write('-f\nbar') + ... fp.write('-f\nbar') >>> parser = argparse.ArgumentParser(fromfile_prefix_chars='@') >>> parser.add_argument('-f') >>> parser.parse_args(['-f', 'foo', '@args.txt']) @@ -1109,9 +1109,9 @@ argument:: >>> parser = argparse.ArgumentParser(prog='frobble') >>> parser.add_argument('--foo', action='store_true', - ... help='foo the bars before frobbling') + ... help='foo the bars before frobbling') >>> parser.add_argument('bar', nargs='+', - ... help='one of the bars to be frobbled') + ... help='one of the bars to be frobbled') >>> parser.parse_args(['-h']) usage: frobble [-h] [--foo] bar [bar ...] @@ -1129,7 +1129,7 @@ specifiers include the program name, ``%(prog)s`` and most keyword arguments to >>> parser = argparse.ArgumentParser(prog='frobble') >>> parser.add_argument('bar', nargs='?', type=int, default=42, - ... help='the bar to %(prog)s (default: %(default)s)') + ... help='the bar to %(prog)s (default: %(default)s)') >>> parser.print_help() usage: frobble [-h] [bar] @@ -1468,10 +1468,10 @@ interactive prompt:: >>> parser = argparse.ArgumentParser() >>> parser.add_argument( ... 'integers', metavar='int', type=int, choices=range(10), - ... nargs='+', help='an integer in the range 0..9') + ... nargs='+', help='an integer in the range 0..9') >>> parser.add_argument( ... '--sum', dest='accumulate', action='store_const', const=sum, - ... default=max, help='sum the integers (default: find the max)') + ... default=max, help='sum the integers (default: find the max)') >>> parser.parse_args(['1', '2', '3', '4']) Namespace(accumulate=<built-in function max>, integers=[1, 2, 3, 4]) >>> parser.parse_args(['1', '2', '3', '4', '--sum']) |