[issue26967] argparse: allow_abbrev=False stops -vv from working

Michael Kruse report at bugs.python.org
Fri May 6 10:53:26 EDT 2016


Michael Kruse added the comment:

I think the allow_abbrev option should be orthogonal on how short options are parsed. I am using parse_known_args() to forward the unrecognized args to another program, therefore allow_abbrev=False is essential.

There is a special handling for short options in the consume_optional and _get_option_tuples to allow them being concatenated with one dash, as commonly done with short options (eg. "tar -czf file"). I interpret allow_abbrev as an option to avoid matching non-exiting options that should be forwarded to the other program; '-vv' is an existing option with the same meaning as '-v -v'.

This would also mean that parse_known_args(['-vz']) (where '-v' is a registered argument, but '-z' is not) matches '-v' and returns '-z' as unknown argument; but I don't know whether you want to go that far. It is difficult to interpret whether '-verify' should mean '-v -e -r -i -f -y' or '--verify' (but this is why there are double-dash options), especially when the first letter is not a registered short option.

----------

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


More information about the Python-bugs-list mailing list