PyDocs

Nav

Command-line interface libraries

ArgumentParser.parse_known_args

  • ArgumentParser.parse_known_args(args=None, namespace=None)
Sometimes a script only needs to handle a specific set of command-line arguments, leaving any unrecognized arguments for another script or program. In these cases, the parse_known_args() method can be useful.
1 Example
>>> parser = argparse.ArgumentParser()
>>> parser.add_argument('--foo', action='store_true')
>>> parser.add_argument('bar')
>>> parser.parse_known_args(['--foo', '--badger', 'BAR', 'spam'])
(Namespace(bar='BAR', foo=True), ['--badger', 'spam'])
from the Python docs
See Also
No see-alsos for argparse/ArgumentParser.parse_known_args
0 Notes
No notes for ArgumentParser.parse_known_args