[issue41600] Expected behavior of argparse given quoted strings

Eric V. Smith report at bugs.python.org
Thu Aug 20 09:44:24 EDT 2020


Eric V. Smith <eric at trueblade.com> added the comment:

This is all working as designed. We do not want to modify argparse to split parameters.

You probably want to split the input with shlex.split(). See https://stackoverflow.com/questions/44945815/how-to-split-a-string-into-command-line-arguments-like-the-shell-in-python

You shouldn't need to mutate sys.argv. You can break the input up into multiple strings with shlex.split() (or whatever you decide to use) and pass those to ArgumentParser.parse_args().

----------
nosy: +eric.smith

_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue41600>
_______________________________________


More information about the Python-bugs-list mailing list