Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import argparse
- if __name__ == '__main__':
- parser = argparse.ArgumentParser(
- formatter_class=argparse.ArgumentDefaultsHelpFormatter
- )
- sub_parser = parser.add_subparsers(title='sub commands',
- help='sub commands help')
- foo = sub_parser.add_parser('foo')
- foo.add_argument(
- '--a',
- action='store',
- default='1234',
- help='A'
- )
- parser.parse_args(['foo', '--help'])
- usage: test_args.py foo [-h] [--a A]
- optional arguments:
- -h, --help show this help message and exit
- --a A A
- Process finished with exit code 0
Add Comment
Please, Sign In to add comment