Command line arguments??

Benjamin Kaplan benjamin.kaplan at case.edu
Mon Nov 16 18:23:58 EST 2009


On Mon, Nov 16, 2009 at 6:18 PM, rantingrick <rantingrick at gmail.com> wrote:
> I am currently having "fun" with command line arguments in a windows
> environment. If i get a path that has spaces anywhere in it my script
> gets the wrong arguments from sys.argv. You guy's probably know what i
> am talking about. Heres and example.
>
> 'C:\\Python26\\Python.exe C:\\echo.py C:\\New Folder\\text.txt'
>
> inside my script i get the following result from sys.argv
>
> ['C:\\Python26\\Python.exe', 'C:\\echo.py', 'C:\\New', 'Folder\
> \text.txt']
>
> So i've got a few options
>  1. have people replace every space in all file paths system wide
> (sucks)
>  2. Create a custom parser, join the argv list, parse it...(maybe)
>  3. please tell me there is an option 3? (hopefully)
> --
> http://mail.python.org/mailman/listinfo/python-list
>

The same thing you have to do with every command line program - wrap
it in quotes.
C:\\Python26\\python.exe C:\\echo.py "C:\\New Folder\\text.txt"



More information about the Python-list mailing list