Handle spaces in argparse input
For those who can't parse arguments and still get "error: unrecognized arguments:" I found a workaround:
parser.add_argument('-d', '--dmp', nargs='+', ...)
opts = parser.parse_args()
and then when you want to use it just do
' '.join(opts.dmp)
Simple solution: argparse considers a space filled string as a single argument if it is encapsulated by quotation marks.
This input worked and "solved" the problem:
-d "C:\SMTHNG\Name with spaces\MORE\file.csv"
NOTICE: argument has "" around it.
Bumped into this problem today too.
-d "foo bar"
didn't help. I had to add the equal sign
-d="foo bar"
and then it did work.