I would like to parse a string like this:
-o 1 --long \"Some long string\"
into this:
[\"-o\", \"1\", \"--long\", \'Some
I believe you want the shlex module.
>>> import shlex >>> shlex.split('-o 1 --long "Some long string"') ['-o', '1', '--long', 'Some long string']