Message192222
As discussed in issue 16468, a metavar may be used to provide an alternative representation of a choices option. However if a metvar like 'range(20)' is used, usage formatter strips off the '()'.
>>> parser.add_argument('foo', type=int,
choices=range(20), metavar='range(0,20)')
>>> parser.format_usage()
# expect: 'usage: PROG [-h] range(0,20)\n'
# actual: 'usage: PROG [-h] range0,20\n'
This is done by a line in the help formater that removes excess mutually exclusive group notation:
HelpFormatter._format_actions_usage
...
text = _re.sub(r'\(([^|]*)\)', r'\1', text)
A solution is to change this line to distinguish between a case like ' (...)' and 'range(...)'
text = _re.sub(r'( )\(([^|]*)\)', r'\1\2', text) |
|
Date |
User |
Action |
Args |
2013-07-03 06:16:51 | paul.j3 | set | recipients:
+ paul.j3 |
2013-07-03 06:16:51 | paul.j3 | set | messageid: <1372832211.16.0.544648995095.issue18349@psf.upfronthosting.co.za> |
2013-07-03 06:16:51 | paul.j3 | link | issue18349 messages |
2013-07-03 06:16:50 | paul.j3 | create | |
|