sys.argv with quoted strings as option argument

Satya Arjunan satya at
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:

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

However, sys.argv breaks the arguments whenever it encounter spaces, 
like this:
['./', '--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 Nanda Vel Arjunan
Institute for Advanced Biosciences
Keio University

More information about the Python-list mailing list