Removing option from optparse

GustavoTabares at gmail.com GustavoTabares at gmail.com
Mon May 12 10:41:19 EDT 2008


Hello,

I'm trying to figure out if the following is a bug or if I'm using the
remove_option in the wrong way.

#!/usr/bin/env python
import optparse
parser = optparse.OptionParser()
parser.add_option("--test", help="This is a test option")
parser.remove_option('--test')
print parser.parse_args()

this will output:
(<Values at 0x6beb8: {'test': None}>, [])

If you execute the --help on the file above you will not see --test as
expected. I'm curious as to why parse_args is still returning this as
an option.

Thanks,
Gustavo



More information about the Python-list mailing list