Here's my simple test.py script:
import argparse
parser = argparse.ArgumentParser('A long string that goes on and on and on'
'and on and on and on and on and on and on '
'and on and on and on and on and on and on '
'and on and on and on and on and on and on ')
me_group = parser.add_mutually_exclusive_group()
me_group.add_argument('-f', help=argparse.SUPPRESS)
me_group.add_argument('-o', help=argparse.SUPPRESS)
parser.add_argument('-t', help='c')
parser.parse_args()
When I run the following:
python test.py --help
I get this AssertionError:
...
File "/usr/lib/python2.7/argparse.py", line 332, in _format_usage
assert ' '.join(opt_parts) == opt_usage
AssertionError
This seems to only happen when I suppress all of the arguments in a mutually-exclusive group. If one or more is not suppressed, then everything works fine. If I print out the two sides of the comparison:
print ' '.join(opt_parts)
print opt_usage
I get the following:
[-h] [-t T]
[-h] [-t T]
Looks like there's an extra space there. Any idea why this would be? Is there anything I am doing incorrectly?