paul j3 added the comment:

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.

----------

_______________________________________
Python tracker <rep...@bugs.python.org>
<http://bugs.python.org/issue12713>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to