Raw command line arguments

Gabriel Genellina gagsl-py2 at yahoo.com.ar
Fri Apr 24 13:06:56 EDT 2009


En Fri, 24 Apr 2009 06:40:23 -0300, Enchanter <ensoul.magazine at gmail.com>  
escribió:

> How to pass the raw command line arguments to the python?

That depends on the OS or the shell you're using.

> 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.

I guess you're using Windows:

gg>type show.py
import sys
print sys.argv

gg>python show.py one txt -c """Test Only""" {Help}
['show.py', 'one', 'txt', '-c', '"Test Only"', '{Help}']

Two double quotes represent a single one. And you have to enclose the  
whole argument in quotes too because of the space character.

-- 
Gabriel Genellina




More information about the Python-list mailing list