On Fri, Apr 24, 2009 at 2:40 AM, Enchanter <ensoul.magaz...@gmail.com> wrote: > How to pass the raw command line arguments to the python? > > Such as: > > mypython.py txt -c "Test Only" {Help} > > > The arguments I hope to get is: > > txt -c "Test Only" {Help} -- Keep the > quotation marks in the arguments.
Remember that the quotes are parsed by the shell before python ever receives the arguments, so you have to deal with it in whatever is calling python. Recall/note the differences between: rm foo bar #delete foo and delete bar rm "foo bar" #delete one file with a space in its name but no quotes in its name rm 'foo"bar"baz' #delete one file with double-quotes in its name rm "foo\"bar\"baz" #delete the same file as in the previous example Therefore, you need to invoke the script differently to take account of the shell's quote processing by adding another set of quotes, like so: mypython.py txt -c '"Test Only"' {Help} #or alternatively: mypython.py txt -c "\"Test Only\"" {Help} Cheers, Chris -- I have a blog: http://blog.rebertia.com -- http://mail.python.org/mailman/listinfo/python-list