[New-bugs-announce] [issue16418] argparse with many choices can generate absurdly long usage message

Juraj Variny report at bugs.python.org
Tue Nov 6 00:11:51 CET 2012


New submission from Juraj Variny:

Example:

parser.add_argument("-p","--port", help="Listening port", type=int, choices=range(1, 65535),default=8007,required = False)

generates this usage text:

usage: agent.py [-h]
                [-p {1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30, <...snip...> ,65522,65523,65524,65525,65526,65527,65528,65529,65530,65531,65532,65533,65534}]

optional arguments:
  -h, --help            show this help message and exit
  -p {1,2,3,4,5,6,7,8,9,10,11,12,13,14, <...snip...> ,65525,65526,65527,65528,65529,65530,65531,65532,65533,65534}
                        Listening port

----------
components: Library (Lib)
messages: 174947
nosy: Juraj.Variny
priority: normal
severity: normal
status: open
title: argparse with many choices can generate absurdly long usage message
type: behavior
versions: Python 2.7

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue16418>
_______________________________________


More information about the New-bugs-announce mailing list