let optionparse.Optionparser ignore unknown command line switches.

Michele Simionato michele.simionato at gmail.com
Tue Aug 3 01:28:15 EDT 2010


On Aug 1, 1:08 pm, News123 <news1... at free.fr> wrote:
> I wondered, whether there's a simple/standard way to let
> the Optionparser just ignore unknown command line switches.
>
> thanks in advance for any ideas

I will plug in my own work on plac: http://pypi.python.org/pypi/plac
Your problem would be solved as follows:

import plac

@plac.annotations(test=('a flag', 'flag', 't'))
def main(test, *ignore):
    print test, ignore

if __name__ == '__main__':
    plac.call(main, ["-t","--ignoreme_and_dont_fail"])



More information about the Python-list mailing list