Message273319
| Author |
paul.j3 |
| Recipients |
bethard, chriz, eric.araujo, ned.deily, paul.j3, pwil3058, python-dev, tshepang, vinay.sajip, zach.ware |
| Date |
2016年08月21日.21:35:29 |
| SpamBayes Score |
-1.0 |
| Marked as misclassified |
Yes |
| Message-id |
<1471815329.42.0.121266351701.issue12713@psf.upfronthosting.co.za> |
| In-reply-to |
| Content |
Another failure case:
parser.add_argument('--int', type=int, choices=[10,15,25])
'--int 15` puts 'int=15' in the Namespace.
'--int 2' puts 'int=2' in the Namespace, because it matches the 'str(25)'.
'--int 1' raises an error in the ambiguity error formatting code:
'choices': ', '.join(ac)}
This last error could be corrected with:
'choices': ', '.join(map(repr, ac))
=================
The initial message for this issue stated:
So that this feature is not foisted on every programmer that uses
argparse it could be made an option to the ArgumentParser class with
the (possible) additional refinement of specifying a minimum number
of characters for the abbreviations.
That was ignored in the subsequent discussion and patches.
Other Choices issues
http://bugs.python.org/issue16468 - argparse only supports iterable choices
http://bugs.python.org/issue16418 - long choices
http://bugs.python.org/issue16977 - choices='abc' case
I recommend closing this issue, and depend on aliases for subparsers abbreviations. The interaction with 'choices' is just too complicated to handle as proposed here. |
|