When I provide the Python input argparse, I donβt like it, it calls SystemExit with code 2, which means "There is no such file or directory . " Why use this error code?
import argparse import errno parser = argparse.ArgumentParser() parser.add_argument('arg') try: parser.parse_args([]) except SystemExit as se: print("Got error code {} which is {} in errno" .format(se.code, errno.errorcode[se.code]))
produces this conclusion:
usage: se.py [-h] arg se.py: error: too few arguments Got error code 2 which is ENOENT in errno
python errno argparse
kuzzooroo
source share