sys.argv with quoted strings as option argument

Diez B. Roggisch deets_noospaam at
Thu Dec 11 00:39:24 CET 2003

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

Under Linux, this works. So most probably this is a problem of your shell
(under windows?) Anther solution might be to specify every argument with
its own key like this:

./myprogram --include-dir=foo --include-dir=bar

Using getopt, you can build up the list on your own.


More information about the Python-list mailing list