When I give Python's argparse input it doesn't like, it raises a SystemExit with a code of 2, which seems to mean "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 output:
usage: se.py [-h] arg
se.py: error: too few arguments
Got error code 2 which is ENOENT in errno
errnocodes are an entirely different standard.errnoerror codes, not about whyargparseuses 2 as the exit code. You are making the same mistake as the OP here.