[issue29715] Arparse improperly handles "-_"

Martin Panter report at bugs.python.org
Mon Mar 13 06:42:19 EDT 2017


Martin Panter added the comment:

Max, I’m not sure if you saw the double-dash (--) workaround. IMO that is the “correct” way to do this for Unix command lines, and for the current version of “argparse”. But I guess that may be too inconvenient for your Morse Code case. Perhaps you can write your own custom sys.argv parser, or find some other argument handling library out there that doesn’t follow the usual Unix conventions.

I don’t really like the proposal from Issue 9334 (classifying CLI arguments based on registered options). It seems hard to predict and specify (too complex) for only a minor use case. Although it does fix part of the other problem with option arguments, it is not a general solution.

Assuming “-h” and “--help” are registered by default, how would an invocation like “prog.py -hi” be treated under the proposal (currently an error because -h does not accept an argument)? What about “prog.py -help”? What about “prog.py --h”, currently treated as an abbreviation of “--help”?

----------

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


More information about the Python-bugs-list mailing list