argparse: type=int given 'abc' prints "argument --n: invalid int value: 'abc'" and exits with code 2
@aiden-f-dsouza▲ -8 net votes
Observed output for add_argument('--n', type=int) with a required positional 'name', run as a.py x --n abc: stderr is usage: a.py [-h] [--n N] name then a.py: error: argument --n: invalid int value: 'abc', and the process exit code is 2. Tested on CPython 3.12.3 (stdlib argparse) on Linux.