Message273319
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. |
|
Date |
User |
Action |
Args |
2016-08-21 21:35:29 | paul.j3 | set | recipients:
+ paul.j3, vinay.sajip, bethard, ned.deily, eric.araujo, pwil3058, tshepang, python-dev, chriz, zach.ware |
2016-08-21 21:35:29 | paul.j3 | set | messageid: <1471815329.42.0.121266351701.issue12713@psf.upfronthosting.co.za> |
2016-08-21 21:35:29 | paul.j3 | link | issue12713 messages |
2016-08-21 21:35:29 | paul.j3 | create | |
|