[issue42973] argparse: mixing optional and positional arguments... not again
paul j3
report at bugs.python.org
Wed Jan 27 16:13:16 EST 2021
paul j3 <ajipanca at gmail.com> added the comment:
Sometimes patches have unforeseen benefits. My earlier patch for this issue, parse_intermixed_args, has been useful beyond the OP's case.
https://stackoverflow.com/questions/50916124/allow-positional-command-line-arguments-with-nargs-to-be-seperated-by-a-flag
https://bugs.python.org/issue15112
argparse: nargs='*' positional argument doesn't accept any items if preceded by an option and another positional
With
usage: test.py [-h] [-a A] b [c]
and
test.py B -a A C
has problems because the optional '[c]' positional is used up when 'b' is processed. Intermixed gets around this by first processing '-a', and then handling 'b [c]' together.
----------
_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue42973>
_______________________________________
More information about the Python-bugs-list
mailing list