[docs] [issue16418] argparse with many choices can generate absurdly long usage message

Chris Jerdonek report at bugs.python.org
Tue Nov 13 15:03:28 CET 2012


Chris Jerdonek added the comment:

> Does argparse actually convert (x)range objects to a list or set (the help indicates the latter) for internal use?

No, it leaves the provided choices argument as is.

Here is what the documentation says argparse accepts: "Any object that supports the *in* operator can be passed as the choices value, so dict objects, set objects, custom containers, etc. are all supported."  And here is the code for testing containment:

http://hg.python.org/cpython/file/ee7b713fec71/Lib/argparse.py#l2284

Terry, are you okay with the proposed documentation patch?

Special-casing the display of range values seems like an enhancement request to me rather than a bug.  I would suggest that be handled as an enhancement request targeted initially for Python 3.4.  I would be happy to create a new issue for that.  Alternatively, it could be considered as a second patch on this issue.

----------

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


More information about the docs mailing list