If you run argparse inside another python script , for example, when testing inside unittest , then printing sys.argv will only print the arguments to the main script, for example:
['C: \ eclipse \ plugins \ org.python.pydev_5.9.2.201708151115 \ pysrc \ runfiles.py', 'C: \ eclipse_workspace \ test_file_search.py', '-port', '58454', '--verbosity ',' 0 ']
In this case, you should use vars to repeat the argparse arguments:
parser = argparse.ArgumentParser(... ... args = parser.parse_args() for arg in vars(args): print arg, getattr(args, arg)
Thanks: fooobar.com/questions/219657 / ...
Noam manos
source share