[Python-Dev] argparse ambiguity handling

P.J. Eby pje at telecommunity.com
Tue Apr 20 21:48:15 CEST 2010


At 03:27 PM 4/20/2010 -0400, Neal Becker wrote:
>I have a preference to allow at least exact matches to succeed even in the
>case of ambiguity - mainly because I accidentally created this already once,
>and I feel it's better to at least work somewhat.  Not sure if there is any
>more elegant solution.  OTOH, I feel this is somewhat inelegant, as it
>appears to treat exact match as a special case.

How about throwing an error the moment you define a set of options 
that create this potential ambiguity?  ;-)  (i.e. force you to define 
--string1 and --string2 instead of --string and --string2)

(Either that, or have an option to turn off ambiguous guessing, and 
throw the error unless you've turned it off.)



More information about the Python-Dev mailing list