parse_known_args()
intended for the convenience of the programmer writing the program, and not what the user of the program should worry about. If you correctly define your command line arguments, argparse
gives you something similar automatically:
>>> import argparse >>> p = argparse.ArgumentParser(prog='command') >>> x=p.add_argument("foo", nargs=argparse.REMAINDER) >>> p.parse_args(["--help"]) usage: command [-h] ... positional arguments: foo optional arguments: -h, --help show this help message and exit
source share