This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author paul.j3
Recipients paul.j3
Date 2013-07-03.06:16:49
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <>
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:

       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:51paul.j3setrecipients: + paul.j3
2013-07-03 06:16:51paul.j3setmessageid: <>
2013-07-03 06:16:51paul.j3linkissue18349 messages
2013-07-03 06:16:50paul.j3create