sys.argv with quoted strings as option argument
Diez B. Roggisch
deets_noospaam at web.de
Wed Dec 10 18:39:24 EST 2003
> 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?
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.
Diez
More information about the Python-list
mailing list