Iterating over optparse options

Miki Tebeka tebeka at
Wed Jun 25 13:05:28 CEST 2003

Hello All,

Couldn't find it in the manual ...
Is there a way to iterate over the options optparse parser finds?
What I like to to is:
... <set default options>
parser = OptionParser()
... # Configure parser
options, args = parser.parse_args()
for opt, value in options:
    OPTIONS[opt] = value
The rational is that I have a program with many command line options.
Instead of going over all of them I'd like to set my defaults and change
only what is needed.


More information about the Python-list mailing list