sys.argv with quoted strings as option argument

Satya Arjunan satya at ttck.keio.ac.jp
Thu Dec 11 08:12:25 CET 2003


Hi everyone,

I would like to send an option argument which is a quoted string with 
whitespaces to a python program. For example:

$ ./myprogram.py --includedir="/usr/include /usr/local/include" 
--libdir="/usr/lib /usr/local/lib"

However, sys.argv breaks the arguments whenever it encounter spaces, 
like this:
['./myprogram.py', '--includedir=/usr/include', '/usr/local/include', 
'--libdir=/usr/lib', '/usr/local/lib']

So I can't seem to use getopt or optik to process such cases. Is there a 
good way where I can preserve such option arguments with whitespaces?

satya

-- 
Satya Nanda Vel Arjunan
Institute for Advanced Biosciences
Keio University
http://satya.host.sk/







More information about the Python-list mailing list