I'm working on a python script that takes several command line flags, currently parsed by hand. I'd like to change the script to parse them with OptionParser from the optparse module. However, currently the script invokes a subprocess, and any flags the script doesn't understand it assumes are meant to be passed to the subprocess. But if I switch to using OptionParser, any options I haven't added to my parser will cause an error, instead of it ignoring those and letting me pass them onto the subprocess.
What's the best/most-pythonic way to handle this? I could subclass OptionParser and override its exit() and error() methods as suggested by the docs (http://www.python.org/doc/2.4/lib/optparse-how-optik-handles-errors.html) and have them do nothing, but there are some errors I probably don't want to ignore (like if the user tries to pass a string to a known flag that takes an int). -- http://mail.python.org/mailman/listinfo/python-list