As far as I can tell, both getopt
and optparse
must be used with a pre-defined list of permitted commandline options. Is there a way to get them (or another option-parsing module I don't know about) to accept any option that starts with -
?
Reason: I have a short python command line program that basically delegates to another module with an extended option API. I want to do a little bit of commandline processing in my program, and pass all unrecognized options to the delegate module. While I could hack it in pure python, I would prefer to rely on one of the standard modules. Both short and long options should be supported (-o
, --long-opt
and --long-option=argument
), but obviously I don't expect to support the syntax --long-option argument
for an unknown option.