Message247465
Hi,
Here is a sample of what I do:
>>> import argparse
>>> main_parser = argparse.ArgumentParser()
>>> group_ex = main_parser.add_mutually_exclusive_group()
>>> group_ex1 = group_ex.add_argument_group()
>>> group_ex1.add_argument('-a', '--atest', help="help about -a") and None
>>> group_ex1.add_argument('-b', '--btest', help="help about -b") and None
>>> group_ex.add_argument('-c', '--ctest', help="help about -c") and None
>>> main_parser.print_help()
usage: [-h] [-a ATEST] [-b BTEST] [-c CTEST]
optional arguments:
-h, --help show this help message and exit
-c CTEST, --ctest CTEST
help about -c
Here is what I would except as help message:
>>> main_parser.print_help()
usage: [-h] [[-a ATEST] [-b BTEST]] | [-c CTEST]
optional arguments:
-h, --help show this help message and exit
-c CTEST, --ctest CTEST
help about -c
-a ATEST, --atest ATEST
help about -a
-b BTEST, --btest BTEST
help about -b
Options '-a' and '-b' are not displayed in the help message due to the "add_mutually_exclusive_group". |
|
Date |
User |
Action |
Args |
2015-07-27 12:52:06 | Alexandre.Badez | set | recipients:
+ Alexandre.Badez |
2015-07-27 12:52:06 | Alexandre.Badez | set | messageid: <1438001526.73.0.776043102355.issue24736@psf.upfronthosting.co.za> |
2015-07-27 12:52:06 | Alexandre.Badez | link | issue24736 messages |
2015-07-27 12:52:06 | Alexandre.Badez | create | |
|