Possible Duplicate:
What’s the reverse of shlex.split?
How do I convert a list of command line parameters, like argv
to a single string for command line?
" ".join(argv)
is not the correct solution as it will not escape the strings with spaces correctly.
Example: ./test.py -v --simulate --action removePage --title "AAA BBB"
If you try this the last argument is AAA BBB
without quotes but if I try to rebuild the command line with join I will get a wrong result.
Note: I know that I can get the command line as a string, but in my case I cannot rely on that, I need a solution that converts a list of arguments to a proper command line.