In python's OptionParser
, how can I instruct it to ignore undefined options supplied to method parse_args
?
e.g.
I've only defined option --foo
for my OptionParser
instance, but I call parse_args
with list: [ '--foo', '--bar' ]
I don't care if it filters them out of the original list. I just want undefined options ignored.
The reason I'm doing this is because I'm using SCons' AddOption
interface to add custom build options. However, some of those options guide the declaration of the targets. Thus I need to parse them out of sys.argv
at different points in the script without having access to all the options. In the end, the top level Scons OptionParser
will catch all the undefined options in the command line.